Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitLogger ¶
InitLogger initializes the logger.
Example ¶
_stderr := os.Stderr os.Stderr = os.Stdout location, _ := time.LoadLocation("UTC") time.Local = location zerolog.TimestampFunc = func() time.Time { return time.Unix(0, 0).UTC() } // Test log format // empty format should log console InitLogger(&config.Log{Format: ""}) log.Info().Msg("test empty") // common format should log console InitLogger(&config.Log{Format: "common"}) log.Info().Msg("test common") // json format should log json InitLogger(&config.Log{Format: "json"}) log.Info().Msg("test json") // Test log level // info level should not log debug InitLogger(&config.Log{Level: "info"}) log.Info().Msg("test level info") log.Debug().Msg("test level info -- ignored") // debug level should add caller InitLogger(&config.Log{Level: "debug"}) log.Info().Msg("test level debug")
Output: 1970-01-01T00:00:00Z INF test empty 1970-01-01T00:00:00Z INF test common {"level":"info","time":"1970-01-01T00:00:00Z","message":"test json"} 1970-01-01T00:00:00Z INF test level info 1970-01-01T00:00:00Z INF logger_test.go:87 > test level debug
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.