Peter Kurfer
a720b0ee41
* supports HTTP * support TLS interception e.g. for HTTPS * support CA generation via cli * first draft of plugin API * support commands from plugins * includes Dockerfile * includes basic configuration
42 lines
933 B
Go
42 lines
933 B
Go
package logging
|
|
|
|
import (
|
|
"go.uber.org/zap"
|
|
"go.uber.org/zap/zapcore"
|
|
"strings"
|
|
)
|
|
|
|
var (
|
|
loggingConfig = zap.NewProductionConfig()
|
|
)
|
|
|
|
func ConfigureLogging(
|
|
level zap.AtomicLevel,
|
|
developmentLogging bool,
|
|
initialFields map[string]interface{},
|
|
) {
|
|
loggingConfig.Level = level
|
|
loggingConfig.Development = developmentLogging
|
|
loggingConfig.InitialFields = initialFields
|
|
}
|
|
|
|
func ParseLevel(levelString string) zap.AtomicLevel {
|
|
switch strings.ToLower(levelString) {
|
|
case "debug":
|
|
return zap.NewAtomicLevelAt(zapcore.DebugLevel)
|
|
case "info":
|
|
return zap.NewAtomicLevelAt(zapcore.InfoLevel)
|
|
case "warn":
|
|
return zap.NewAtomicLevelAt(zapcore.WarnLevel)
|
|
case "error":
|
|
return zap.NewAtomicLevelAt(zapcore.ErrorLevel)
|
|
case "fatal":
|
|
return zap.NewAtomicLevelAt(zapcore.FatalLevel)
|
|
default:
|
|
return zap.NewAtomicLevelAt(zapcore.InfoLevel)
|
|
}
|
|
}
|
|
|
|
func CreateLogger() (*zap.Logger, error) {
|
|
return loggingConfig.Build()
|
|
}
|