log

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// String is an alias of zap.String
	String = zap.String
	// Bytes is an alias of zap.Bytes
	Bytes = zap.ByteString
	// Duration is an alias of zap.Duration
	Duration = zap.Duration
	// Int8 is an alias of zap.Int8
	Int8 = zap.Int8
	// Int32 is an alias of zap.Int32
	Int32 = zap.Int32
	// Int is an alias of zap.Int
	Int = zap.Int
	// Int64 is an alias of zap.Int64
	Int64 = zap.Int64
	// Uint8 is an alias of zap.Uint8
	Uint8 = zap.Uint8
	// Uint32 is an alias of zap.Uint32
	Uint32 = zap.Uint32
	// Uint is an alias of zap.Uint
	Uint = zap.Uint
	// Uint64 is an alias of zap.Uint64
	Uint64 = zap.Uint64
	// Float64 is an alias of zap.Float64
	Float64 = zap.Float64
	// Any is an alias of zap.Any
	Any = zap.Any
)

Functions

func Debug

func Debug(ctx context.Context, msg string, fields ...Field)

Debug logs are typically voluminous, and are usually disabled in production

func Debugf

func Debugf(msg string, fields ...Field)

Debugf logs are typically voluminous without context and are usually disabled in production

func Error

func Error(ctx context.Context, msg string, fields ...Field)

Error logs are high-priority. If an application is running smoothly, it shouldn't generate any error-Level logs

func Errorf

func Errorf(msg string, fields ...Field)

Errorf logs are high-priority without context If an application is running smoothly, it shouldn't generate any error-Level logs.

func Info

func Info(ctx context.Context, msg string, fields ...Field)

Info logs Info Level

func Infof

func Infof(msg string, fields ...Field)

Infof logs Info Level without context

func Json added in v1.3.6

func Json(obj interface{}) string

func JsonBytes added in v1.3.6

func JsonBytes(obj interface{}) []byte

func JsonForm added in v1.3.6

func JsonForm(form url.Values) []byte

func Panic

func Panic(ctx context.Context, msg string, fields ...Field)

Panic logs a message then panic

func Panicf

func Panicf(msg string, fields ...Field)

Panic logs a message then panic without context

func Warn

func Warn(ctx context.Context, msg string, fields ...Field)

Warn logs are more important than Info, but don't need individual human review

func Warnf

func Warnf(msg string, fields ...Field)

Warnf logs are more important than Info but don't need individual human review

Types

type Config

type Config struct {
	// Dir log output directory
	Dir string
	// Name log output file name
	Name string
	// Level log level
	Level string
	// CallerSkip log depth
	CallerSkip int
	// FlushInterval log flush interval
	FlushInterval time.Duration
	// Debug log mode, default true
	Debug bool
	// WatchConfig whether watch config file changes
	WatchConfig bool
	// EnableAsyncLog whether flush log async
	EnableAsyncLog bool
	// DisableStacktrace where log stack details if run into error
	DisableStacktrace bool
	// MaxSize max size of log file, it'll rotate log automatically if exceed the max size
	MaxSize int
	// MaxAge max duration of store logs
	MaxAge int
	// MaxBackup max files of backup logs
	MaxBackup int
	// Sensitives filter keywords
	Sensitives []string
	// Placeholder filter keyword replacement
	Placeholder string
}

Config log configs

type Field

type Field = zap.Field

Field is an alias of zap.Field

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger logger definition

func New

func New(config *Config) *Logger

New returns a Logger instance

func (*Logger) SetLevel

func (l *Logger) SetLevel(level string)

SetLevel set log level

func (*Logger) Sync

func (l *Logger) Sync() error

Sync flush log

Jump to

Keyboard shortcuts

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