Documentation ¶
Overview ¶
Package logging holds the code to have a uniform logging style for all output.
Package logging - common package, used for logging purposes. Is a wrapper around 3-rd party logging framework.
Example (GetLogTarget) ¶
conf := viper.New() conf.Set("LOG_TARGET", "FILE") conf.Set("LOG_DIR", ".") conf.Set("LOG_FILE", "test.out") v := getLogTarget(conf) conf.Set("LOG_TARGET", "stdout") v = getLogTarget(conf) fmt.Printf("%T\n", v)
Output: *os.File
Example (NewLogTargetFile) ¶
conf := viper.New() conf.Set("LOG_DIR", "") newLogTargetFile(conf) conf.Set("LOG_TARGET", "FILE") conf.Set("LOG_DIR", ".") conf.Set("LOG_FILE", "test.out") newLogTargetFile(conf) conf.Set("LOG_TARGET", "stdout") newLogTargetFile(conf)
Output:
Example (SetLogLevel) ¶
conf := viper.New() conf.Set("LOG_LEVEL", "AA") setLogLevel(conf) conf.Set("LOG_LEVEL", "debug") setLogLevel(conf) fmt.Printf("%v\n", zerolog.GlobalLevel())
Output: debug
Example (SetTimeFormat_RFC) ¶
conf := viper.New() conf.Set("LOG_TIME_FORMAT", "RFC3339") setTimeFormat(conf) fmt.Println(zerolog.TimeFieldFormat)
Output: 2006-01-02T15:04:05Z07:00
Example (SetTimeFormat_Unix) ¶
conf := viper.New() conf.Set("LOG_TIME_FORMAT", "Unix") setTimeFormat(conf) fmt.Println(zerolog.TimeFieldFormat)
Output:
Index ¶
- func Debug(msg string, args ...interface{})
- func Error(msg string, args ...interface{})
- func Error1(err error)
- func ErrorAndPanic(msg string, args ...interface{})
- func Fatal(msg string, args ...interface{})
- func Info(msg string, args ...interface{})
- func InfoEnabled() bool
- func Init(conf *viper.Viper) zerolog.Logger
- func Init1(logLevel string, logTarget string, logServiceName string) zerolog.Logger
- func Panic(msg string, args ...interface{})
- func SetLogLevel(logLevel string)
- func Trace(msg string, args ...interface{})
- func Warn(msg string, args ...interface{})
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrorAndPanic ¶
func ErrorAndPanic(msg string, args ...interface{})
ErrorAndPanic is now deprecated. It is equivalent to Panic.
Example ¶
defer func() { if err := recover(); err != nil { fmt.Println(err) } }() ErrorAndPanic("test ErrorAndPanic message")
Output: test ErrorAndPanic message
func Init ¶
Example ¶
conf := viper.New() l := Init(conf) fmt.Printf("%T\n", l)
Output: zerolog.Logger
func Init1 ¶
Init1 initialises the logger without a Viper object
Example ¶
l := Init1("logLevel", "init1.out", "logServiceName") fmt.Printf("%T\n", l)
Output: zerolog.Logger
func Panic ¶
func Panic(msg string, args ...interface{})
Example ¶
defer func() { if err := recover(); err != nil { fmt.Println(err) } }() Panic("test Panic message")
Output: test Panic message
func SetLogLevel ¶
func SetLogLevel(logLevel string)
Example ¶
SetLogLevel("AA") SetLogLevel("debug") fmt.Printf("%v\n", zerolog.GlobalLevel())
Output: debug
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.