moving logging function to common setting up client logging and db
This commit is contained in:
29
common/logging.go
Normal file
29
common/logging.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
)
|
||||
|
||||
// SetLogLevel takes in the integer supplied and turns it into a log level
|
||||
func SetLogLevel(loglevel int) (level zerolog.Level, err error) {
|
||||
switch loglevel {
|
||||
case -1:
|
||||
return zerolog.TraceLevel, nil
|
||||
case 0:
|
||||
return zerolog.DebugLevel, nil
|
||||
case 1:
|
||||
return zerolog.InfoLevel, nil
|
||||
case 2:
|
||||
return zerolog.WarnLevel, nil
|
||||
case 3:
|
||||
return zerolog.ErrorLevel, nil
|
||||
case 4:
|
||||
return zerolog.FatalLevel, nil
|
||||
case 5:
|
||||
return zerolog.PanicLevel, nil
|
||||
default:
|
||||
return zerolog.InfoLevel, fmt.Errorf("incorrect log level set, setting it to info level")
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user