logger

package
v1.0.0-beta Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

README

logger

logger公共代码库,基于zap封装

Documentation

Index

Constants

View Source
const (
	MODULE_REQUEST = "[Request]"
	MODULE_SYSTEM  = "[System]"

	MODULE_BRIEF = "[Brief]"
	MODULE_EVENT = "[Event]"

	DefaultStackTraceLevel = "PANIC"
)

Log module

Variables

This section is empty.

Functions

func RefreshLogConfig

func RefreshLogConfig(config *LogConfig)

RefreshLogConfig refresh core levels of modules at initiation time of core module or refresh core levels of modules dynamically at running time.

func SetLogConfig

func SetLogConfig(config *LogConfig)

SetLogConfig set the config of logger module, called in initialization of config module

Types

type LogConfig

type LogConfig struct {
	ConfigFile string    `yaml:"config_file"`
	LoggerIns  LoggerIns `yaml:"log"`
}

LogConfig the config of core module

func DefaultLogConfig

func DefaultLogConfig() *LogConfig

DefaultLogConfig create default config for core module

type LogModuleConfig

type LogModuleConfig struct {
	LogLevelDefault string            `yaml:"log_level_default"`
	LogLevels       map[string]string `yaml:"log_levels"`
	FilePath        string            `yaml:"file_path"`
	MaxAge          int               `yaml:"max_age"`
	RotationTime    int               `yaml:"rotation_time"`
	RotationSize    int64             `yaml:"rotation_size"`
	LogInConsole    bool              `yaml:"log_in_console"`
	ShowColor       bool              `yaml:"show_color"`
	StackTraceLevel string            `yaml:"stack_trace_level"`
}

LogModuleConfig 设置不同模块的日志

func GetDefaultLogModuleConfig

func GetDefaultLogModuleConfig() LogModuleConfig

GetDefaultLogModuleConfig create a default core config of node

type Logger

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

Logger is an implementation of service logger.

func GetLogger

func GetLogger(name string) *Logger

GetLogger find or create a Logger with module name, usually called in initialization of all module. After one module get the logger, the module can use it forever until the program terminate.

func GetLoggerByService

func GetLoggerByService(name, serviceName string) *Logger

GetLoggerByChain find the Logger object with module name and serviceName, usually called in initialization of all module. One module can get a logger for each chain, then logger can be use forever until the program terminate.

func (*Logger) Debug

func (l *Logger) Debug(args ...interface{})

func (*Logger) DebugDynamic

func (l *Logger) DebugDynamic(getStr func() string)

func (*Logger) Debugf

func (l *Logger) Debugf(format string, args ...interface{})

func (*Logger) Debugw

func (l *Logger) Debugw(msg string, keysAndValues ...interface{})

func (*Logger) Error

func (l *Logger) Error(args ...interface{})

func (*Logger) Errorf

func (l *Logger) Errorf(format string, args ...interface{})

func (*Logger) Errorw

func (l *Logger) Errorw(msg string, keysAndValues ...interface{})

func (*Logger) Fatal

func (l *Logger) Fatal(args ...interface{})

func (*Logger) Fatalf

func (l *Logger) Fatalf(format string, args ...interface{})

func (*Logger) Fatalw

func (l *Logger) Fatalw(msg string, keysAndValues ...interface{})

func (*Logger) Info

func (l *Logger) Info(args ...interface{})

func (*Logger) InfoDynamic

func (l *Logger) InfoDynamic(getStr func() string)

func (*Logger) Infof

func (l *Logger) Infof(format string, args ...interface{})

func (*Logger) Infow

func (l *Logger) Infow(msg string, keysAndValues ...interface{})

func (*Logger) Logger

func (l *Logger) Logger() *zap.SugaredLogger

func (*Logger) Panic

func (l *Logger) Panic(args ...interface{})

func (*Logger) Panicf

func (l *Logger) Panicf(format string, args ...interface{})

func (*Logger) Panicw

func (l *Logger) Panicw(msg string, keysAndValues ...interface{})

func (*Logger) SetLogger

func (l *Logger) SetLogger(logger *zap.SugaredLogger)

SetLogger set logger.

func (*Logger) Warn

func (l *Logger) Warn(args ...interface{})

func (*Logger) Warnf

func (l *Logger) Warnf(format string, args ...interface{})

func (*Logger) Warnw

func (l *Logger) Warnw(msg string, keysAndValues ...interface{})

type LoggerIns

type LoggerIns struct {
	RequestLog LogModuleConfig `yaml:"request"`
	SystemLog  LogModuleConfig `yaml:"system"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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