Documentation ¶
Index ¶
- Constants
- func CustomLevelEncoder(level zapcore.Level, enc zapcore.PrimitiveArrayEncoder)
- func CustomTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
- func InitSugarLogger(logConfig *LogConfig, writer ...io.Writer) (*zap.SugaredLogger, zap.AtomicLevel)
- type FilteredLogger
- func (fl *FilteredLogger) Debug(args ...interface{})
- func (fl *FilteredLogger) Debugf(template string, args ...interface{})
- func (fl *FilteredLogger) Error(args ...interface{})
- func (fl *FilteredLogger) Errorf(template string, args ...interface{})
- func (fl *FilteredLogger) Filter(msg string)
- func (fl *FilteredLogger) Filterf(format string, a ...interface{})
- func (fl *FilteredLogger) Info(args ...interface{})
- func (fl *FilteredLogger) Infof(template string, args ...interface{})
- func (fl *FilteredLogger) Warn(args ...interface{})
- func (fl *FilteredLogger) Warnf(template string, args ...interface{})
- type LOG_LEVEL
- type LogConfig
- type LoggerInterface
Constants ¶
View Source
const ( DEBUG = "DEBUG" INFO = "INFO" WARN = "WARN" ERROR = "ERROR" )
日志级别,配置文件定义的常量
View Source
const ( DEFAULT_MAX_AGE = 365 // 日志最长保存时间,单位:天 DEFAULT_ROTATION_TIME = 6 // 日志滚动间隔,单位:小时 DEFAULT_ROTATION_SIZE = 100 // 默认的日志滚动大小,单位:MB )
日志切割默认配置
View Source
const ( ColorBlack color = iota + 30 ColorRed ColorGreen ColorYellow ColorBlue ColorMagenta ColorCyan ColorWhite )
View Source
const (
ROTATION_SIZE_MB = 1024 * 1024
)
日志滚动单位
Variables ¶
This section is empty.
Functions ¶
func CustomLevelEncoder ¶
func CustomLevelEncoder(level zapcore.Level, enc zapcore.PrimitiveArrayEncoder)
func CustomTimeEncoder ¶
func CustomTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
func InitSugarLogger ¶
func InitSugarLogger(logConfig *LogConfig, writer ...io.Writer) (*zap.SugaredLogger, zap.AtomicLevel)
Types ¶
type FilteredLogger ¶ added in v2.3.4
type FilteredLogger struct {
// contains filtered or unexported fields
}
func InitFilterLogger ¶ added in v2.3.4
func InitFilterLogger(logConfig *LogConfig, writer ...io.Writer) (*FilteredLogger, zap.AtomicLevel)
func NewFilteredLogger ¶ added in v2.3.4
func NewFilteredLogger(logger *zap.SugaredLogger, sensitiveDataFiltering bool, sensitiveDataEncryptionKey string, ) *FilteredLogger
func (*FilteredLogger) Debug ¶ added in v2.3.4
func (fl *FilteredLogger) Debug(args ...interface{})
func (*FilteredLogger) Debugf ¶ added in v2.3.4
func (fl *FilteredLogger) Debugf(template string, args ...interface{})
func (*FilteredLogger) Error ¶ added in v2.3.4
func (fl *FilteredLogger) Error(args ...interface{})
func (*FilteredLogger) Errorf ¶ added in v2.3.4
func (fl *FilteredLogger) Errorf(template string, args ...interface{})
func (*FilteredLogger) Filter ¶ added in v2.3.4
func (fl *FilteredLogger) Filter(msg string)
func (*FilteredLogger) Filterf ¶ added in v2.3.4
func (fl *FilteredLogger) Filterf(format string, a ...interface{})
func (*FilteredLogger) Info ¶ added in v2.3.4
func (fl *FilteredLogger) Info(args ...interface{})
func (*FilteredLogger) Infof ¶ added in v2.3.4
func (fl *FilteredLogger) Infof(template string, args ...interface{})
func (*FilteredLogger) Warn ¶ added in v2.3.4
func (fl *FilteredLogger) Warn(args ...interface{})
func (*FilteredLogger) Warnf ¶ added in v2.3.4
func (fl *FilteredLogger) Warnf(template string, args ...interface{})
type LogConfig ¶
type LogConfig struct { Module string // module: module name ChainId string // chainId: chain id 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 IsBrief bool // if true, only show log, won't print log level、caller func and line // StackTraceLevel record a stack trace for all messages at or above a given level. // Empty string or invalid level will not open stack trace. StackTraceLevel string IsCompress bool //启用压缩 NoCompressCount int //最近n个文件不压缩 HmacKey string //密钥 ArchivePath string //日志归档路径 SensitiveDataFiltering bool //启用敏感数据过滤 SensitiveDataEncryptionKey string //启用敏感数据加密(密钥) MultipleLogFiles bool //多日志文件,true:不同级别日志写入不同文件夹 }
type LoggerInterface ¶
type LoggerInterface interface { Debugf(format string, args ...interface{}) Infof(format string, args ...interface{}) Warnf(format string, args ...interface{}) Errorf(format string, args ...interface{}) Debug(args ...interface{}) Info(args ...interface{}) Warn(args ...interface{}) Error(args ...interface{}) }
Click to show internal directories.
Click to hide internal directories.