Documentation ¶
Index ¶
- func Debug(args ...interface{})
- func Debugf(template string, args ...interface{})
- func Error(args ...interface{})
- func Errorf(template string, args ...interface{})
- func Info(args ...interface{})
- func Infof(template string, args ...interface{})
- func Init()
- type Logger
- func (l *Logger) Debug(args ...interface{})
- func (l *Logger) Debugf(template string, args ...interface{})
- func (l *Logger) Error(args ...interface{})
- func (l *Logger) Errorf(template string, args ...interface{})
- func (l *Logger) Info(args ...interface{})
- func (l *Logger) Infof(template string, args ...interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Debug ¶
func Debug(args ...interface{})
Debug logs a message. This is a convinience function for logger.Debug().
func Debugf ¶
func Debugf(template string, args ...interface{})
Debugf logs a templated message. This is a convinience function for logger.Debugf().
func Error ¶
func Error(args ...interface{})
Error logs a message. This is a convinience function for logger.Error().
func Errorf ¶
func Errorf(template string, args ...interface{})
Errorf logs a templated message. This is a convinience function for logger.Errorf().
func Info ¶
func Info(args ...interface{})
Info logs a message. This is a convinience function for logger.Info().
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a general structured logger.
func With ¶
func With(args ...interface{}) *Logger
With returns a logger with custom structured fields added to the root of the log entries. The arguments are passed to the underlying sugared zap logger. See the zap documentation for details. If an argument is a zap.Field it is logged accordingly, otherwise the arguments are treated as key value pairs.
For example,
zlog.With( "hello", "world", zap.String("zapKey", "zapValue"), "user", User{Name: "alice"}, ).Info("msg")
logs the following fields (some fields omitted)
{ "message": "msg", "hello": "world", "zapKey": "zapValue", "user": { "name": "alice" }}
func WithFields ¶
func WithFields(args ...interface{}) *Logger
WithFields returns a logger with custom structured fields added to the 'fields' key in the log entries. The arguments are passed to the underlying sugared zap logger. See the zap documentation for details. If an argument is a zap.Field it is logged accordingly, otherwise the arguments are treated as key value pairs.
For example,
zlog.WithFields( "hello", "world", zap.String("zapKey", "zapValue"), "user", User{Name: "alice"}, ).Info("msg")
logs the following fields (some fields omitted)
{ "message": "msg", "fields": { "hello": "world", "zapKey": "zapValue", "user": { "name": "alice" }}}