logx

package
v0.0.0-...-421db18 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogFields

type LogFields map[string]interface{}

LogFields alias for fields

type Logger

type Logger interface {
	// logur interface
	logur.Logger

	// logur context aware interface
	logur.LoggerContext

	// go-cloud interface
	requestlog.Logger

	// WithFields interface extensions
	WithFields(fields map[string]interface{}) Logger

	// WithError interface extensions
	WithError(err error) Logger
}

Logger logx interface

func NewLogger

func NewLogger(opts ...Opts) Logger

NewLogger returns a Logger implementation

type Options

type Options struct {
	// Development configures the logger to use a Zap development config
	// (stacktraces on warnings, no sampling), otherwise a Zap production
	// config will be used (stacktraces on errors, sampling).
	Development bool
	// Encoder configures how Zap will encode the output.  Defaults to
	// console when Development is true and JSON otherwise
	Encoder zapcore.Encoder
	// DestWritter controls the destination of the log output.  Defaults to
	// os.Stderr.
	DestWritter io.Writer
	// Level configures the verbosity of the logging.  Defaults to Debug when
	// Development is true and Info otherwise
	Level zapcore.LevelEnabler
	// StacktraceLevel is the level at and above which stacktraces will
	// be recorded for all messages. Defaults to Warn when Development
	// is true and Error otherwise
	StacktraceLevel zapcore.LevelEnabler
	// ZapOpts allows passing arbitrary zap.Options to configure on the
	// underlying Zap logger.
	ZapOpts []zap.Option
}

Options contains all possible settings

func (*Options) BindFlags

func (o *Options) BindFlags(fs *pflag.FlagSet)

BindFlags will parse the given flagset for zap option flags and set the log options accordingly

 zap-devel: Development Mode defaults(encoder=consoleEncoder,logLevel=Debug,stackTraceLevel=Warn)
			  Production Mode defaults(encoder=jsonEncoder,logLevel=Info,stackTraceLevel=Error)
 log-encoder: Zap log encoding ('json' or 'console')
 log-level:  Zap Level to configure the verbosity of logging. Can be one of 'debug', 'info', 'error',
			       or any integer value > 0 which corresponds to custom debug levels of increasing verbosity")
 stacktrace-level: Zap Level at and above which stacktraces are captured (one of 'warn' or 'error')

type Opts

type Opts func(*Options)

Opts allows to manipulate Options

func UseFlagOptions

func UseFlagOptions(in *Options) Opts

UseFlagOptions configures the logger to use the Options set by parsing zap option flags from the CLI.

opts := zap.Options{}
opts.BindFlags(flag.CommandLine)
log := zap.New(zap.UseFlagOptions(&opts))

Jump to

Keyboard shortcuts

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