Skip to content

Commit

Permalink
Merge branch 'ft/logger-use_type_alias'
Browse files Browse the repository at this point in the history
  • Loading branch information
NgoKimPhu committed Feb 29, 2024
2 parents 909558a + b3a3602 commit 7479090
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions klog/klog.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ func DefaultLogger() Logger {
return logger.DefaultLogger()
}

type Logger logger.Logger
type Logger = logger.Logger

var log logger.Logger
var log Logger

type Configuration struct {
EnableConsole bool
Expand All @@ -24,13 +24,13 @@ type Configuration struct {
FileLocation string
}

type LoggerBackend logger.LoggerBackend
type LoggerBackend = logger.LoggerBackend

const (
// LoggerBackendZap logging using Uber's zap backend
LoggerBackendZap = LoggerBackend(logger.LoggerBackendZap)
LoggerBackendZap = logger.LoggerBackendZap
// LoggerBackendLogrus logging using logrus backend
LoggerBackendLogrus = LoggerBackend(logger.LoggerBackendLogrus)
LoggerBackendLogrus = logger.LoggerBackendLogrus
)

func InitLogger(config Configuration, backend LoggerBackend) (Logger, error) {
Expand All @@ -43,7 +43,7 @@ func InitLogger(config Configuration, backend LoggerBackend) (Logger, error) {
FileJSONFormat: config.FileJSONFormat,
FileLevel: config.FileLevel,
FileLocation: config.FileLocation,
}, logger.LoggerBackend(backend))
}, backend)
return log, err
}

Expand All @@ -63,7 +63,7 @@ func NewLogger(config Configuration, backend LoggerBackend) (Logger, error) {
FileJSONFormat: config.FileJSONFormat,
FileLevel: config.FileLevel,
FileLocation: config.FileLocation,
}, logger.LoggerBackend(backend))
}, backend)
}

type CtxKeyLogger struct{}
Expand Down Expand Up @@ -129,10 +129,10 @@ func Fatalf(ctx context.Context, format string, args ...any) {
LoggerFromCtx(ctx).Fatalf(format, args...)
}

type Fields logger.Fields
type Fields = logger.Fields

func WithFields(ctx context.Context, keyValues Fields) Logger {
return LoggerFromCtx(ctx).WithFields(logger.Fields(keyValues))
return LoggerFromCtx(ctx).WithFields(keyValues)
}

func GetDelegate(ctx context.Context) any {
Expand Down

0 comments on commit 7479090

Please sign in to comment.