log

package module
v0.0.0-...-c330695 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2020 License: MIT Imports: 8 Imported by: 9

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 SetLogger

func SetLogger(instance LoggerFactory)

SetLogger 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 {
	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

Directories

Path Synopsis
Package grpczaphelper implements multiple helper function
Package grpczaphelper implements multiple helper function

Jump to

Keyboard shortcuts

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