Documentation ¶
Index ¶
- Constants
- Variables
- func Any(key string, value interface{}) zap.Field
- func ByteString(key string, val []byte) zap.Field
- func Debug(msg string, fields ...zap.Field)
- func Error(msg string, fields ...zap.Field)
- func ErrorField(err error) zap.Field
- func Fatal(msg string, fields ...zap.Field)
- func Info(msg string, fields ...zap.Field)
- func InfoField(v interface{}) zap.Field
- func Level2FileName(level zap.AtomicLevel) string
- func LogRotatePeriod(log *lumberjack.Logger, periodSecond int64)
- func NewLog(config *LogConfig) *zap.Logger
- func SetGlobalLog(appName string, prod bool, opts ...OptionFunc)
- func String(key string, value string) zap.Field
- func Warn(msg string, fields ...zap.Field)
- type FormatEnum
- type FormatTime
- type LevelEnum
- type LogConfig
- type LogHook
- type OptionFunc
- func WithAppNameOption(v string) OptionFunc
- func WithDirOption(v string) OptionFunc
- func WithFormatOption(v FormatEnum) OptionFunc
- func WithHooksOption(hooks ...LogHook) OptionFunc
- func WithLevelOption(v LevelEnum) OptionFunc
- func WithLocalTimeOption(v bool) OptionFunc
- func WithMaxSizeOption(v int) OptionFunc
- func WithMultiWriteOption(v bool) OptionFunc
- func WithRotatePeriodSecondOption(v int64) OptionFunc
Constants ¶
View Source
const ( FormatEnumJSON FormatEnum = "json" FormatEnumConsole FormatEnum = "console" DefaultRotatePeriodSecond int64 = 60 * 60 * 24 // 一天 )
Variables ¶
View Source
var ( LevelEnumDebug = zap.NewAtomicLevelAt(zapcore.DebugLevel) LevelEnumInfo = zap.NewAtomicLevelAt(zapcore.InfoLevel) LevelEnumWarn = zap.NewAtomicLevelAt(zapcore.WarnLevel) LevelEnumError = zap.NewAtomicLevelAt(zapcore.ErrorLevel) )
Functions ¶
func ByteString ¶
ByteString 会把[]byte转成string 注意 Any() 会把[]byte转成 binary
func Debug ¶
Debug logs a message at DebugLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
func ErrorField ¶
func Fatal ¶
Fatal logs a message at FatalLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
The logger then calls os.Exit(1), even if logging at FatalLevel is disabled.
func LogRotatePeriod ¶
func LogRotatePeriod(log *lumberjack.Logger, periodSecond int64)
func SetGlobalLog ¶
func SetGlobalLog(appName string, prod bool, opts ...OptionFunc)
Types ¶
type FormatEnum ¶
type FormatEnum string
type FormatTime ¶
type FormatTime = zapcore.TimeEncoder
type LevelEnum ¶
type LevelEnum = zap.AtomicLevel
type LogConfig ¶
type LogConfig struct { // hook Hooks []LogHook // contains filtered or unexported fields }
type OptionFunc ¶
type OptionFunc func(*LogConfig)
func WithAppNameOption ¶
func WithAppNameOption(v string) OptionFunc
func WithDirOption ¶
func WithDirOption(v string) OptionFunc
func WithFormatOption ¶
func WithFormatOption(v FormatEnum) OptionFunc
func WithHooksOption ¶
func WithHooksOption(hooks ...LogHook) OptionFunc
func WithLevelOption ¶
func WithLevelOption(v LevelEnum) OptionFunc
func WithLocalTimeOption ¶
func WithLocalTimeOption(v bool) OptionFunc
func WithMaxSizeOption ¶
func WithMaxSizeOption(v int) OptionFunc
func WithMultiWriteOption ¶
func WithMultiWriteOption(v bool) OptionFunc
func WithRotatePeriodSecondOption ¶
func WithRotatePeriodSecondOption(v int64) OptionFunc
Click to show internal directories.
Click to hide internal directories.