func CloseFileOutput(next func(error))
CloseFileOutput [INTERNAL USE ONLY] Closes the file descriptor of log data if used
func FmtBlue(msg string) string
FmtBlue Colorize the given string
func FmtDBlue(msg string) string
FmtDBlue Colorize the given string
func FmtGreen(msg string) string
FmtGreen Colorize the given string
func FmtGrey(msg string) string
FmtGrey Colorize the given string
func FmtLBlue(msg string) string
FmtLBlue Colorize the given string
func FmtPurple(msg string) string
FmtPurple Colorize the given string
func FmtRed(msg string) string
FmtRed Colorize the given string
func FmtRedBg(msg string) string
FmtRedBg Colorize the given string
func FmtYellow(msg string) string
FmtYellow Colorize the given string
func FormatStruct(cb func(v interface{}) string)
FormatStruct assigns an optional callback to be called from Verbosef, Networkf, Sysf, Debugf, Noticef, Infof, Warnf, Errorf, and Fatalf to format struct variable being passed.
[CRITICALLY IMPORTANT] Do not use mutex lock or functions that uses mutex lock of any kind internally to avoid possible mutext dead-lock. [CRITICALLY IMPORTANT] Do not attempt to print maps to avoid possible fatal error of concurrent map read and write.
func IsDebug() bool
IsDebug returns true if the log level is debug
func IsError() bool
IsError returns true if the log level is error
func IsFatal() bool
IsFatal returns true if the log level is fatal
func IsInfo() bool
IsInfo returns true if the log level is info
func IsNetwork() bool
IsNetwork returns true if the log level is network
func IsNotice() bool
IsNotice returns true if the log level is notice
func IsSys() bool
IsSys returns true if the log level is sys
func IsVerbose() bool
IsVerbose returns true if the log level is verbose
func IsWarn() bool
IsWarn returns true if the log level is warn
func Level(_level int)
Level Sets logging level
func SetCustomOutput(custom func(formatted bool, name string, prefix string, level string, vals []interface{}) string)
SetCustomOutput Registers a custom function to create a log output string
func SetDebugLevel()
SetDebugLevel set log level to debug
func SetErrorLevel()
SetErrorLevel set log level to error
func SetFatalLevel()
SetFatalLevel set log level to fatal
func SetInfoLevel()
SetInfoLevel set log level to info
func SetNetworkLevel()
SetNetworkLevel set log level to sys
func SetNoticeLevel()
SetNoticeLevel set log level to notice
func SetPrefix(prefix string)
SetPrefix Sets a prefix for every log
func SetSysLevel()
SetSysLevel set log level to sys
func SetVerboseLevel()
SetVerboseLevel set log level to verbose
func SetWarnLevel()
SetWarnLevel set log level to warn
func Setup(confpath string)
Setup Load a configuration file into memory - pass an empty string to load nothing
func UpdateConfigs(configs map[string]interface{})
UpdateConfigs Apply configurations It can be executed in runtime to update the configurations also
func UseCustomOutput()
UseCustomOutput Enables custom output for all log data.
func UseJSONFormat()
UseJSONFormat formats the log with JSON format.
func UseStackdriverLogging()
UseStackdriverLogging is an alias of UseJSONFormat
Logger Logger data structure
type Logger struct { Name string // contains filtered or unexported fields }
func New(name string) *Logger
New Creates a new logger
func (logger *Logger) Debug(vals ...interface{})
Debug Outputs a log to stdout stream
func (logger *Logger) Debugf(vals ...interface{})
Debugf returns an instance of FormattedText struct.
This is useful when you need to format the logging message.
[IMPORTANT] FormattedText supports JSON format log output as well.
Example:
logger.Debugf("This is a log", "intVar", 123, "stringVar", "aaa", "object", obj) // output: // This is a log intVar=[Value=="123" Type=int Pointer=NA] stringVar=[Value="aaa" Type=string Pointer=NA] object=[Value={"Name":"exampleObject","Counter":100} Type=*Object Pointer=0x0ff234]
func (logger *Logger) DisableCustom()
DisableCustom blocks logger.Write()
func (logger *Logger) EnableCustom()
EnableCustom allows logger.Write()
func (logger *Logger) Error(vals ...interface{})
Error Outputs a log to stdout stream
func (logger *Logger) Errorf(vals ...interface{})
Errorf returns an instance of FormattedText struct.
This is useful when you need to format the logging message.
[IMPORTANT] FormattedText supports JSON format log output as well.
Example:
logger.Errorf("This is a log", "intVar", 123, "stringVar", "aaa", "object", obj) // output: // This is a log intVar=[Value=="123" Type=int Pointer=NA] stringVar=[Value="aaa" Type=string Pointer=NA] object=[Value={"Name":"exampleObject","Counter":100} Type=*Object Pointer=0x0ff234]
func (logger *Logger) Fatal(vals ...interface{})
Fatal Outputs a log to stdout stream
func (logger *Logger) Fatalf(vals ...interface{})
Fatalf returns an instance of FormattedText struct.
This is useful when you need to format the logging message.
[IMPORTANT] FormattedText supports JSON format log output as well.
Example:
logger.Fatalf("This is a log", "intVar", 123, "stringVar", "aaa", "object", obj) // output: // This is a log intVar=[Value=="123" Type=int Pointer=NA] stringVar=[Value="aaa" Type=string Pointer=NA] object=[Value={"Name":"exampleObject","Counter":100} Type=*Object Pointer=0x0ff234]
func (logger *Logger) Fmt(msg string, vals ...interface{}) string
Fmt uses fmt.Sprintf internally
func (logger *Logger) FmtDebug(vals ...interface{}) string
FmtDebug Formats given strings and returns it for logging purpose
func (logger *Logger) FmtError(vals ...interface{}) string
FmtError Formats given strings and returns it for logging purpose
func (logger *Logger) FmtFatal(vals ...interface{}) string
FmtFatal Formats given strings and returns it for logging purpose
func (logger *Logger) FmtInfo(vals ...interface{}) string
FmtInfo Formats given strings and returns it for logging purpose
func (logger *Logger) FmtNetwork(vals ...interface{}) string
FmtNetwork Formats given strings and returns it for logging purpose
func (logger *Logger) FmtNotice(vals ...interface{}) string
FmtNotice Formats given strings and returns it for logging purpose
func (logger *Logger) FmtSys(vals ...interface{}) string
FmtSys Formats given strings and returns it for logging purpose
func (logger *Logger) FmtVerbose(vals ...interface{}) string
FmtVerbose Formats given strings and returns it for logging purpose
func (logger *Logger) FmtWarn(vals ...interface{}) string
FmtWarn Formats given strings and returns it for logging purpose
func (logger *Logger) FormatStruct(cb func(v interface{}) string)
FormatStruct assigns an optional callback to be called from Verbosef, Networkf, Sysf, Debugf, Noticef, Infof, Warnf, Errorf, and Fatalf to format struct variable being passed.
func (logger *Logger) Info(vals ...interface{})
Info Outputs a log to stdout stream
func (logger *Logger) Infof(vals ...interface{})
Infof returns an instance of FormattedText struct.
This is useful when you need to format the logging message.
[IMPORTANT] FormattedText supports JSON format log output as well.
Example:
logger.Infof("This is a log", "intVar", 123, "stringVar", "aaa", "object", obj) // output: // This is a log intVar=[Value=="123" Type=int Pointer=NA] stringVar=[Value="aaa" Type=string Pointer=NA] object=[Value={"Name":"exampleObject","Counter":100} Type=*Object Pointer=0x0ff234]
func (logger *Logger) Network(vals ...interface{})
Network Outputs a log to stdout stream
func (logger *Logger) Networkf(vals ...interface{})
Networkf returns an instance of FormattedText struct.
This is useful when you need to format the logging message.
[IMPORTANT] FormattedText supports JSON format log output as well.
Example:
logger.Networkf("This is a log", "intVar", 123, "stringVar", "aaa", "object", obj) // output: // This is a log intVar=[Value=="123" Type=int Pointer=NA] stringVar=[Value="aaa" Type=string Pointer=NA] object=[Value={"Name":"exampleObject","Counter":100} Type=*Object Pointer=0x0ff234]
func (logger *Logger) Notice(vals ...interface{})
Notice Outputs a log to stdout stream
func (logger *Logger) Noticef(vals ...interface{})
Noticef returns an instance of FormattedText struct.
This is useful when you need to format the logging message.
[IMPORTANT] FormattedText supports JSON format log output as well.
Example:
logger.Noticef("This is a log", "intVar", 123, "stringVar", "aaa", "object", obj) // output: // This is a log intVar=[Value=="123" Type=int Pointer=NA] stringVar=[Value="aaa" Type=string Pointer=NA] object=[Value={"Name":"exampleObject","Counter":100} Type=*Object Pointer=0x0ff234]
func (logger *Logger) Sys(vals ...interface{})
Sys Outputs a log to stdout stream
func (logger *Logger) Sysf(vals ...interface{})
Sysf returns an instance of FormattedText struct.
This is useful when you need to format the logging message.
[IMPORTANT] FormattedText supports JSON format log output as well.
Example:
logger.Sysf("This is a log", "intVar", 123, "stringVar", "aaa", "object", obj) // output: // This is a log intVar=[Value=="123" Type=int Pointer=NA] stringVar=[Value="aaa" Type=string Pointer=NA] object=[Value={"Name":"exampleObject","Counter":100} Type=*Object Pointer=0x0ff234]
func (logger *Logger) Trace(vals ...interface{})
Trace Outputs a log to stdout stream as Sys level log with stack trace. Useful for debugging
func (logger *Logger) Verbose(vals ...interface{})
Verbose Outputs a log to stdout stream
func (logger *Logger) Verbosef(vals ...interface{})
Verbosef returns an instance of FormattedText struct.
This is useful when you need to format the logging message.
[IMPORTANT] FormattedText supports JSON format log output as well.
Example:
logger.Verbosef("This is a log", "intVar", 123, "stringVar", "aaa", "object", obj) // output: // This is a log intVar=[Value=="123" Type=int Pointer=NA] stringVar=[Value="aaa" Type=string Pointer=NA] object=[Value={"Name":"exampleObject","Counter":100} Type=*Object Pointer=0x0ff234]
func (logger *Logger) Warn(vals ...interface{})
Warn Outputs a log to stdout stream
func (logger *Logger) Warnf(vals ...interface{})
Warnf returns an instance of FormattedText struct.
This is useful when you need to format the logging message.
[IMPORTANT] FormattedText supports JSON format log output as well.
Example:
logger.Warnf("This is a log", "intVar", 123, "stringVar", "aaa", "object", obj) // output: // This is a log intVar=[Value=="123" Type=int Pointer=NA] stringVar=[Value="aaa" Type=string Pointer=NA] object=[Value={"Name":"exampleObject","Counter":100} Type=*Object Pointer=0x0ff234]
func (logger *Logger) Write(vals ...interface{})
Write outputs a log to stdout stream