Documentation
¶
Overview ¶
Package watermillzap provides the implementation of watermill.LoggerAdapter using go.uber.org/zap.
Index ¶
- func NewLogger(z *zap.Logger) watermill.LoggerAdapter
- type Logger
- func (l *Logger) Debug(msg string, fields watermill.LogFields)
- func (l *Logger) Error(msg string, err error, fields watermill.LogFields)
- func (l *Logger) Info(msg string, fields watermill.LogFields)
- func (l *Logger) Trace(msg string, fields watermill.LogFields)
- func (l *Logger) With(fields watermill.LogFields) watermill.LoggerAdapter
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger implements watermill.LoggerAdapter with *zap.Logger.
func (*Logger) Debug ¶
Debug writes debug log with message and some fields.
Example ¶
logger := NewLogger(zap.NewExample()) logger.Debug("ExampleLogger_Debug", watermill.LogFields{"test_field": 1})
Output: {"level":"debug","msg":"ExampleLogger_Debug","test_field":1}
func (*Logger) Error ¶
Error writes error log with message, error and some fields.
Example ¶
logger := NewLogger(zap.NewExample()) logger.Error("ExampleLogger_Error", errors.New("test error"), watermill.LogFields{"test_field": 1})
Output: {"level":"error","msg":"ExampleLogger_Error","error":"test error","test_field":1}
func (*Logger) Info ¶
Info writes info log with message and some fields.
Example ¶
logger := NewLogger(zap.NewExample()) logger.Info("ExampleLogger_Info", watermill.LogFields{"test_field": 1})
Output: {"level":"info","msg":"ExampleLogger_Info","test_field":1}
func (*Logger) Trace ¶
Trace writes debug log instead of trace log because zap does not support trace level logging.
Example ¶
logger := NewLogger(zap.NewExample()) logger.Trace("ExampleLogger_Trace", watermill.LogFields{"test_field": 1})
Output: {"level":"debug","msg":"ExampleLogger_Trace","test_field":1}
Click to show internal directories.
Click to hide internal directories.