Skip to content

Commit

Permalink
Using byte slices for levels
Browse files Browse the repository at this point in the history
  • Loading branch information
damienstamates authored Aug 21, 2019
1 parent 3ef987b commit 4cd4e91
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions customlogger.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ var _ Logger = &CustomLogger{}

// NewCustomLogger returns a custom logging
// object for the Classy service to use.
func NewCustomLogger(level string, config zapcore.EncoderConfig) *CustomLogger {
func NewCustomLogger(level []byte, config zapcore.EncoderConfig) *CustomLogger {
logLevel := zap.NewAtomicLevel()
logLevel.UnmarshalText([]byte(level))
logLevel.UnmarshalText(level)

return &CustomLogger{
level: logLevel,
Expand Down Expand Up @@ -72,12 +72,12 @@ func interfaceToZapField(iFields ...interface{}) (fields []zapcore.Field) {
}

// SetLevel changes the logger level
func (l *CustomLogger) SetLevel(level string) {
func (l *CustomLogger) SetLevel(level []byte) {
// flush the existing logger before changing to new log level
l.logger.Sync()

// Read in the new zapcore AtomicLevel and apply new zap instance
l.level.UnmarshalText([]byte(level))
l.level.UnmarshalText(level)
l.logger = zap.New(zapcore.NewCore(zapcore.NewJSONEncoder(l.config), zapcore.Lock(l.output), l.level))
}

Expand Down

0 comments on commit 4cd4e91

Please sign in to comment.