Documentation
¶
Index ¶
- Constants
- func DebugF(format string, v ...interface{})
- func ErrorF(format string, v ...interface{})
- func ExportSLog(log *zap.Logger, tag string)
- func GetLogFields() []logField
- func InfoF(format string, v ...interface{})
- func NewLogger(opts ...Option) (*zap.Logger, error)
- func NewRotation(options *Options) (io.Writer, error)
- func PanicF(format string, v ...interface{})
- func RegisterLogField(k string, v LogFieldType)
- func SetSLog(l *ServerLog)
- func Sync()
- func SystemDebug(code LogECode, id LogAccID, path LogPath, token LogToken, ip LogRealIP, ...)
- func SystemError(code LogECode, id LogAccID, path LogPath, token LogToken, ip LogRealIP, ...)
- func SystemInfo(code LogECode, id LogAccID, path LogPath, token LogToken, ip LogRealIP, ...)
- func SystemReqInfo(id LogAccID, path LogPath, token LogToken, ip LogRealIP, format string, ...)
- func SystemWarn(code LogECode, id LogAccID, path LogPath, token LogToken, ip LogRealIP, ...)
- func WarnF(format string, v ...interface{})
- type BaseFlow
- type CommonFlow
- type Helper
- type LogAccID
- type LogECode
- type LogField
- type LogFieldType
- type LogPath
- type LogRealIP
- type LogToken
- type Option
- func WithCaller(c bool) Option
- func WithCallerFunc(c bool) Option
- func WithCallerSkip(c int) Option
- func WithCompress(c bool) Option
- func WithEncoderConf(e *zapcore.EncoderConfig) Option
- func WithGlobPattern(g string) Option
- func WithLevel(l zapcore.Level) Option
- func WithLinkName(l string) Option
- func WithMaxAge(a time.Duration) Option
- func WithMaxBackups(b int) Option
- func WithMaxSize(s int) Option
- func WithOutStd(s bool) Option
- func WithRotationCount(c uint) Option
- func WithRotationSize(s int64) Option
- func WithRotationTime(t time.Duration) Option
- func WithSuffix(s string) Option
- type Options
- type ServerLog
Constants ¶
View Source
const ( ServerTagKey = "ServerTag" PathKey = "path" AccIDKey = "accID" ECodeKey = "eCode" TokenKey = "token" RealIPKey = "realIP" )
View Source
const ( DefaultMaxSize = 1024 DefaultMaxAge = 7 DefaultMaxBackups = 30 DefaultCompress = false DefaultOutStd = false DefaultTimestampFormat = "2006-01-02 15:04:05.000" DefaultLevel = zapcore.InfoLevel // rotatelogs 默认参数 RotateDefaultRotationSize = 1 * 1024 * 1024 * 1024 // 1G RotateDefaultRotationTime = 1 * time.Hour RotateDefaultMaxAge = 0 // if both DefaultMaxAge and DefaultRotationCount are 0, give maxAge a sane default "7 * 24 * time.Hour" RotateDefaultRotationCount = 0 // 0 means this option is disabled. )
Variables ¶
This section is empty.
Functions ¶
func ExportSLog ¶
func GetLogFields ¶
func GetLogFields() []logField
func RegisterLogField ¶
func RegisterLogField(k string, v LogFieldType)
func SystemDebug ¶
func SystemError ¶
func SystemInfo ¶
func SystemReqInfo ¶
func SystemWarn ¶
Types ¶
type BaseFlow ¶
type BaseFlow struct { *CommonFlow BaseFields []zap.Field }
func (*BaseFlow) SetCommon ¶
func (f *BaseFlow) SetCommon(cf *CommonFlow)
func (*BaseFlow) TaDataFields ¶
type Helper ¶
type Helper interface { SystemReqInfo(id LogAccID, path LogPath, token LogToken, ip LogRealIP, format string, v ...interface{}) SystemLog(level zapcore.Level, code LogECode, id LogAccID, path LogPath, token LogToken, ip LogRealIP, format string, v ...interface{}) Log(level zapcore.Level, format string, v ...interface{}) Sync() }
type LogFieldType ¶
type LogFieldType = string
var LogFieldTypeBool LogFieldType = "bool"
var LogFieldTypeDate LogFieldType = "date"
var LogFieldTypeFloat64 LogFieldType = "float64"
var LogFieldTypeInt LogFieldType = "int32"
var LogFieldTypeInt64 LogFieldType = "int64"
var LogFieldTypeString LogFieldType = "string"
var LogFieldTypeUint LogFieldType = "uint32"
var LogFieldTypeUint64 LogFieldType = "uint64"
type Option ¶
func WithCaller ¶
func WithCallerFunc ¶
func WithCallerSkip ¶
func WithCompress ¶
func WithEncoderConf ¶
func WithEncoderConf(e *zapcore.EncoderConfig) Option
func WithLinkName ¶
func WithMaxAge ¶
func WithMaxBackups ¶
func WithMaxSize ¶
func WithOutStd ¶
func WithRotationCount ¶
func WithRotationSize ¶
func WithRotationTime ¶
func WithSuffix ¶
type Options ¶
type Options struct { Suffix string // 日志文件后缀 MaxSize int // 每个日志文件保存的最大尺寸 单位:M MaxAge int // 文件最多保存多少天 MaxBackups int // 日志文件最多保存多少个备份 Compress bool // 是否压缩 OutStd bool // 是否输出到控制台 EncoderConf *zapcore.EncoderConfig // zap日志编码 Level zapcore.Level // 日志等级 Caller bool // 是否打印行号,函数 CallerFunc bool // 是否打印函数 CallerSkip int // Caller skip frame count for caller info // rotatelogs使用参数 // log filename pattern, if GlobPattern is empty, log will not be written to file GlobPattern string // sets the symbolic link name that gets linked to the current file name being used. LinkName string // (bytes) the log file size between rotation RotationSize int64 // the time between rotation RotationTime time.Duration // the max age of a log file before it gets purged from the file system. // if both RotationCount and MaxAge are 0, give maxAge a sane default "7 * 24 * time.Hour" LogMaxAge time.Duration // the number of files should be kept before it gets purged from the file system // if both RotationCount and MaxAge are 0, give maxAge a sane default "7 * 24 * time.Hour" RotationCount uint }
func NewOptions ¶
Click to show internal directories.
Click to hide internal directories.