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 DEBUG = "DEBUG" //INFO info INFO = "INFO" //WARN warn WARN = "WARN" //ERROR error ERROR = "ERROR" )
日志级别,配置文件定义的常量
View Source
const ( DEFAULT_MAX_AGE = 365 // 日志最长保存时间,单位:天 DEFAULT_ROTATION_TIME = 6 // 日志滚动间隔,单位:小时 )
日志切割默认配置
View Source
const ( // ModuleDefault 默认模块 ModuleDefault = "[DEFAULT]" //ModuleCli client模块 ModuleCli = "[CLI]" //ModuleAccessControl 鉴权模块 ModuleAccessControl = "[ACCESS_CONTROL]" //ModuleCrossChainTx 跨链管理模块 ModuleCrossChainTx = "[CROSS_CHAIN_TX_MANAGER]" //ModuleGateway 网关管理模块 ModuleGateway = "[GATEWAY_MANAGER]" //ModuleHandler 路由管理模块 ModuleHandler = "[HANDLER]" //ModuleProve 交易证明模块 ModuleProve = "[PROVE_MANAGER]" //ModuleRelayChain 中继链模块 ModuleRelayChain = "[RELAY_CHAIN_MANAGER]" //ModuleRequest 请求管理模块 ModuleRequest = "[REQUEST_MANAGER]" //ModuleRpcServer rpc server ModuleRpcServer = "[RPC_SERVER]" )
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.