log

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2019 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

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().

func Infof

func Infof(template string, args ...interface{})

Infof logs a templated message. This is a convinience function for logger.Infof().

func Init

func Init()

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" }}}

func (*Logger) Debug

func (l *Logger) Debug(args ...interface{})

Debug logs a message.

func (*Logger) Debugf

func (l *Logger) Debugf(template string, args ...interface{})

Debugf logs a templated message.

func (*Logger) Error

func (l *Logger) Error(args ...interface{})

Error logs a message.

func (*Logger) Errorf

func (l *Logger) Errorf(template string, args ...interface{})

Errorf logs a templated message.

func (*Logger) Info

func (l *Logger) Info(args ...interface{})

Info logs a message.

func (*Logger) Infof

func (l *Logger) Infof(template string, args ...interface{})

Infof logs a templated message.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL