log

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2020 License: Apache-2.0 Imports: 5 Imported by: 20

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = &Options{
	Debug:     false,
	LogLevel:  "info",
	AppName:   "changeme",
	AppID:     "changeme",
	Version:   "0.0.1",
	Revision:  "123456789",
	SentryDSN: "",
}

DefaultOptions defines default logger options

Functions

func CheckErr

func CheckErr(msg string, err error, fields ...zapcore.Field)

CheckErr handles error correctly

func CheckErrCtx

func CheckErrCtx(ctx context.Context, msg string, err error, fields ...zapcore.Field)

CheckErrCtx handles error correctly

func SafeClose

func SafeClose(c io.Closer, msg string, fields ...zapcore.Field)

SafeClose handles the closer error

func SafeCloseCtx

func SafeCloseCtx(ctx context.Context, c io.Closer, msg string, fields ...zapcore.Field)

SafeCloseCtx handles the closer error

func SetLoggerFactory

func SetLoggerFactory(instance LoggerFactory)

SetLoggerFactory defines the default package logger

func Setup

func Setup(ctx context.Context, opts *Options)

Setup the logger

Types

type Logger

type Logger interface {
	Debug(msg string, fields ...zapcore.Field)
	Info(msg string, fields ...zapcore.Field)
	Warn(msg string, fields ...zapcore.Field)
	Error(msg string, fields ...zapcore.Field)
	Fatal(msg string, fields ...zapcore.Field)
	With(fields ...zapcore.Field) Logger
}

Logger is a simplified abstraction of the zap.Logger

func Bg

func Bg() Logger

Bg delegates a no-context logger

func For

func For(ctx context.Context) Logger

For delegates a context logger

type LoggerFactory

type LoggerFactory interface {
	Name() string
	Bg() Logger
	For(context.Context) Logger
	With(...zapcore.Field) LoggerFactory
}

LoggerFactory defines logger factory contract

func Default

func Default() LoggerFactory

Default returns the logger factory

func NewFactory

func NewFactory(logger *zap.Logger) LoggerFactory

NewFactory creates a new Factory.

type Options

type Options struct {
	Debug     bool
	LogLevel  string
	AppName   string
	AppID     string
	Version   string
	Revision  string
	SentryDSN string
}

Options declares logger options for builder

Jump to

Keyboard shortcuts

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