Documentation ¶
Index ¶
- Constants
- func CustomLevelEncoder(level zapcore.Level, enc zapcore.PrimitiveArrayEncoder)
- func CustomTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
- func GetLogger(name string) *zap.SugaredLogger
- func InitLogConfig(config []*LogModuleConfig)
- func InitSugarLogger(loggerConfig *Config) (*zap.SugaredLogger, zap.AtomicLevel)
- type Config
- type LOG_LEVEL
- type LogModuleConfig
Constants ¶
View Source
const ( DEBUG = "DEBUG" INFO = "INFO" WARN = "WARN" ERROR = "ERROR" )
日志级别,配置文件定义的常量
View Source
const ( DEFAULT_MAX_AGE = 365 // 日志最长保存时间,单位:天 DEFAULT_ROTATION_TIME = 6 // 日志滚动间隔,单位:小时 )
日志切割默认配置
View Source
const ( // ModuleDefault 默认模块 ModuleDefault = "[DEFAULT]" // ModuleStart 启动模块 ModuleStart = "[START]" // ModuleRegister 注册模块 ModuleRegister = "[REGISTER]" // ModuleRequest 请求管理模块模块 ModuleRequest = "[REQUEST_MANAGER]" // ModuleChainmakerClient chainmaker链交互模块 ModuleChainmakerClient = "[CHAINMAKER_CLIENT]" // ModuleRpcServer rpc模块 ModuleRpcServer = "[RPC_SERVER]" // ModuleChainClient 链交互模块 ModuleChainClient = "[CHAIN_CLIENT]" // ModuleHandler handler模块 ModuleHandler = "[HANDLER]" // ModuleDb 数据存储模块 ModuleDb = "[DB]" // ModuleChainConfig 链配置模块 ModuleChainConfig )
Variables ¶
This section is empty.
Functions ¶
func CustomLevelEncoder ¶
func CustomLevelEncoder(level zapcore.Level, enc zapcore.PrimitiveArrayEncoder)
CustomLevelEncoder 事件
@param level @param enc
func CustomTimeEncoder ¶
func CustomTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
CustomTimeEncoder 时间
@param t @param enc
func GetLogger ¶
func GetLogger(name string) *zap.SugaredLogger
GetLogger return the instance of SugaredLogger
@param name @return *zap.SugaredLogger
func InitLogConfig ¶
func InitLogConfig(config []*LogModuleConfig)
InitLogConfig set the config of logger module, called in initialization of config module
@param config
func InitSugarLogger ¶
func InitSugarLogger(loggerConfig *Config) (*zap.SugaredLogger, zap.AtomicLevel)
InitSugarLogger init and create SugaredLogger by config
@param loggerConfig @return *zap.SugaredLogger @return zap.AtomicLevel
Types ¶
type Config ¶
type Config struct { Module string // module: module name LogPath string // logPath: log file save path LogLevel LOG_LEVEL // logLevel: log level MaxAge int // maxAge: the maximum number of days to retain old log files RotationTime int // RotationTime: rotation time RotationSize int64 // RotationSize: rotation size Mb JsonFormat bool // jsonFormat: log file use json format ShowLine bool // showLine: show filename and line number LogInConsole bool // logInConsole: show logs in console at the same time ShowColor bool // if true, show color log }
Config is config of logger print
type LogModuleConfig ¶
type LogModuleConfig struct { ModuleName string `mapstructure:"module"` // 归属模块 LogLevel string `mapstructure:"log_level"` // 日志等级 FilePath string `mapstructure:"file_path"` // 日志文件路径 MaxAge int `mapstructure:"max_age"` // 日志留存配置 RotationTime int `mapstructure:"rotation_time"` //日志滚动时间,单位:小时 LogInConsole bool `mapstructure:"log_in_console"` // 在标准输出中打印 ShowColor bool `mapstructure:"show_color"` // 显示颜色 }
LogModuleConfig 日志配置
Click to show internal directories.
Click to hide internal directories.