log

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogDefaultName = "default"

	LogFormatText = "text"
	LogFormatJSON = "json"

	LogConsoleWriter = "console"
	LogFileWriter    = "file"
)

Variables

This section is empty.

Functions

func Debug

func Debug(format string, args ...interface{})

func Error

func Error(format string, args ...interface{})

func Fatal

func Fatal(format string, args ...interface{})

func Info

func Info(format string, args ...interface{})

func Panic

func Panic(format string, args ...interface{})

func ResetDefault

func ResetDefault(loggerGroup LoggerGroup)

func Warn

func Warn(format string, args ...interface{})

Types

type Config

type Config struct {
	Name            string
	Writers         []string
	LogFile         string
	LogLevel        string
	LogFormat       string
	StackTraceLevel string
	MaxSize         int
	MaxBackups      int
	MaxDays         int
	Compress        bool
}

Config is used for logging settings

type Fields

type Fields map[string]interface{}

Fields type, used to pass to `WithFields`.

type Logger

type Logger interface {
	ResetLogger(logger Logger)
	SetFields(Fields)
	GetFields() Fields
	GetField(string) (interface{}, bool)

	WithField(string, interface{}) Logger
	WithFields(Fields) Logger
	WithError(error) Logger

	Debug(string, ...interface{})
	Info(string, ...interface{})
	Warn(string, ...interface{})
	Error(string, ...interface{})
	Panic(string, ...interface{})
	Fatal(string, ...interface{})
}

Logger is the log interface

func Default

func Default() Logger

func GetLogger

func GetLogger(name string, useDefault ...bool) (Logger, bool)

func NewZapLogger

func NewZapLogger(cfg *Config, fields ...Fields) Logger

func WithError

func WithError(err error) Logger

func WithField

func WithField(key string, value interface{}) Logger

func WithFields

func WithFields(fields Fields) Logger

type LoggerGroup

type LoggerGroup interface {
	GetLogger(name string, useDefault ...bool) (Logger, bool)
	Default() Logger
}

func NewZapLoggerGroup

func NewZapLoggerGroup(configs []Config, fields ...Fields) LoggerGroup

Jump to

Keyboard shortcuts

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