michelangelolog

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

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

Go to latest
Published: Jan 19, 2021 License: MIT Imports: 7 Imported by: 0

README

michelangelolog

golang zap

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(msg string, fields ...zap.Field)

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

func Error

func Error(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(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 GetLogger

func GetLogger() *zap.Logger

func GetSurgar

func GetSurgar() *zap.SugaredLogger

func Info

func Info(msg string, fields ...zap.Field)

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

func New

func New(cfg *Config)

初始化日志 New Log

func Panic

func Panic(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 Reset

func Reset(logger *zap.Logger, props *ZapProperties)

重置 Reset

func SetLevel

func SetLevel(l zapcore.Level)

SetLevel alters the logging level.

func Sync

func Sync() error

func Warn

func Warn(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.

Types

type Config

type Config struct {
	// Log level.
	Level string `toml:"level" json:"level"`
	// Log format. one of json, text, or console.
	Format string `toml:"format" json:"format"`
	// File log config.
	File FileLogConfig `toml:"file" json:"file"`
}

Config serializes log related config in toml/json.

type FileLogConfig

type FileLogConfig struct {
	FileDir string `toml:"filedir" json:"filedir"`
	// Log filename, leave empty to disable file log.
	Filename string `toml:"filename" json:"filename"`
	// Max size for a single file, in MB.
	MaxSize int `toml:"max-size" json:"max-size"`
	// Max log keep days, default is never deleting.
	MaxDays int `toml:"max-days" json:"max-days"`
	// Maximum number of old log files to retain.
	MaxBackups int  `toml:"max-backups" json:"max-backups"`
	Compress   bool `toml:"compress" json:"compress"`
}

FileLogConfig serializes file log related config in toml/json.

type ZapProperties

type ZapProperties struct {
	Core   zapcore.Core
	Syncer zapcore.WriteSyncer
	Level  zap.AtomicLevel
}

func InitLogger

func InitLogger(cfg *Config, opts ...zap.Option) (*zap.Logger, *ZapProperties, error)

InitLogger initializes a zap logger.

func InitLoggerWithWriteSyncer

func InitLoggerWithWriteSyncer(cfg *Config, output zapcore.WriteSyncer, opts ...zap.Option) (*zap.Logger, *ZapProperties, error)

InitLoggerWithWriteSyncer initializes a zap logger with specified write syncer.

Jump to

Keyboard shortcuts

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