logger

package module
v0.0.0-...-429ea3c Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModDev = iota
	ModProd
)
View Source
const (
	FormatJSON = iota
	FormatConsole
)
View Source
const (
	// DebugLevel logs are typically voluminous, and are usually disabled in
	// production.
	DebugLevel = zapcore.DebugLevel
	// InfoLevel is the default logging priority.
	InfoLevel = zapcore.InfoLevel
	// WarnLevel logs are more important than Info, but don't need individual
	// human review.
	WarnLevel = zapcore.WarnLevel
	// ErrorLevel logs are high-priority. If an application is running smoothly,
	// it shouldn't generate any error-level logs.
	ErrorLevel = zapcore.ErrorLevel
	// DPanicLevel logs are particularly important errors. In development the
	// logger panics after writing the message.
	DPanicLevel = zapcore.DPanicLevel
	// PanicLevel logs a message, then panics.
	PanicLevel = zapcore.PanicLevel
	// FatalLevel logs a message, then calls os.Exit(1).
	FatalLevel = zapcore.FatalLevel
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CFGLogger

type CFGLogger struct {
	// working mode dev/prod
	Mode string
	// format mode text/json
	LogFormat string
	// log level debug/error
	LogLevel string
}

type Logger

type Logger interface {
	// Info writes a information message.
	Info(args ...interface{})
	// Infof writes a formatted information message.
	Infof(template string, args ...interface{})
	// Infow writes a formatted information message with key-value pairs.
	Infow(template string, args ...interface{})
	// Warn writes a warning message.
	Warn(args ...interface{})
	// Warnf writes a formatted warning message.
	Warnf(template string, args ...interface{})
	// Warnw writes a formatted information message with key-value pairs.
	Warnw(template string, args ...interface{})
	// Error writes an error message.
	Error(args ...interface{})
	// Errorf writes a formatted error message.
	Errorf(template string, args ...interface{})
	// Errorw writes a formatted information message with key-value pairs.
	Errorw(template string, args ...interface{})
	// Debug writes a debug message.
	Debug(args ...interface{})
	// Debugf writes a formatted debug message.
	Debugf(template string, args ...interface{})
	// Debugw writes a formatted information message with key-value pairs.
	Debugw(template string, args ...interface{})
	// Fatal writes a fatal message.
	Fatal(args ...interface{})
	// Fatalf writes a formatted fatal message.
	Fatalf(template string, args ...interface{})
	// With add fields to be used for all logs.
	With(fields ...interface{}) Logger
	// Flush any buffered log entries.
	Flush() error
}

Logger common logger interface.

func LoggerEnv

func LoggerEnv(mode, format int, options ...Option) Logger

LoggerEnv ...

func NewLogger

func NewLogger(cfg *CFGLogger, tags map[string]string) Logger

type Option

type Option func(z *zap.Logger) *zap.Logger

Option options for zap setup

func Name

func Name(name string) Option

Name ...

func Output

func Output(o io.Writer) Option

Output ...

func SelectLevel

func SelectLevel(level int) Option

SelectLevel ...

func Tags

func Tags(fields map[string]string) Option

Tags ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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