change: make API more concise

This commit is contained in:
debugtalk
2021-12-07 21:16:32 +08:00
parent 1a36547ff0
commit bd3aae18f6
15 changed files with 154 additions and 137 deletions

14
log.go
View File

@@ -10,7 +10,15 @@ import (
var log = zlog.Logger
func SetLogLevel(level string) {
// SetLogger configures the log level and format.
func SetLogger(level string, logJSON bool) {
if !logJSON {
setLogPretty()
}
setLogLevel(level)
}
func setLogLevel(level string) {
level = strings.ToUpper(level)
log.Info().Msgf("Set log level to %s", level)
switch level {
@@ -29,9 +37,9 @@ func SetLogLevel(level string) {
}
}
func SetLogPretty() {
func setLogPretty() {
log = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
log.Info().Msg("Set log to pretty console")
log.Info().Msg("Set log to color console other than JSON format.")
}
func GetLogger() zerolog.Logger {