log

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

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

Go to latest
Published: Jan 7, 2022 License: Apache-2.0 Imports: 9 Imported by: 3

README

log

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

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

func Error

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

Error logs a message at ErrorLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.

func Fatal

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

Fatal logs a message at FatalLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.

The logger then calls os.Exit(1), even if logging at FatalLevel is disabled.

func GetLevel

func GetLevel() zapcore.Level

GetLevel gets the logging level.

func Info

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

func Init

func Init(conf *Config)

func L

func L() *zap.Logger

func Panic

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

Panic logs a message at PanicLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.

The logger then panics, even if logging at PanicLevel is disabled.

func ReplaceGlobals

func ReplaceGlobals(logger *zap.Logger, props *Properties) func()

func SetLevel

func SetLevel(l zapcore.Level)

SetLevel alters the logging level.

func Sync

func Sync() error

func Warn

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

Warn logs a message at WarnLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.

func With

func With(fields ...zap.Field) *zap.Logger

With creates a child logger and adds structured context to it. Fields added to the child don't affect the parent, and vice versa.

func WriterHook

func WriterHook(filename string, config *FileConf) lumberjack.Logger

Types

type Config

type Config struct {
	//logger     *zap.Logger
	DebugModel bool
	Level      int
	Encoder    string
	AppName    string
	LogPath    string
	ErrLogPath string
	File       FileConf
	GormOption GormOption
}

type FileConf

type FileConf struct {
	MaxSize    int  // 每个日志文件保存的大小 单位:M
	MaxAge     int  // 文件最多保存多少天
	MaxBackups int  // 日志文件最多保存多少个备份
	Compress   bool // 是否压缩

}

Silent LogLevel = iota + 1 Error Warn Info

type GormOption

type GormOption struct {
	LogLevel                  int
	SlowThreshold             time.Duration
	SkipCallerLookup          bool
	IgnoreRecordNotFoundError bool
}

type Properties

type Properties struct {
	Core      zapcore.Core
	WritesAll zapcore.WriteSyncer
	WritesErr zapcore.WriteSyncer

	Level zap.AtomicLevel
}

func New

func New(conf *Config) (*zap.Logger, *Properties, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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