Documentation ¶
Index ¶
- Constants
- Variables
- func BalanceLog(v ...interface{})
- func BalanceLogf(format string, v ...interface{})
- func CloseCommonLog()
- func CrashLog(v ...interface{})
- func CrashLogf(format string, v ...interface{})
- func DataLog(topic string, keysAndValues ...interface{})
- func DataLogCtx(ctx context.Context, topic string, keysAndValues ...interface{})
- func Debug(v ...interface{})
- func Debugf(format string, v ...interface{})
- func Debugw(msg string, keysAndValues ...interface{})
- func Error(v ...interface{})
- func Errorf(format string, v ...interface{})
- func Errorw(msg string, keysAndValues ...interface{})
- func Fatal(v ...interface{})
- func Fatalf(format string, v ...interface{})
- func GenLog(v ...interface{})
- func GenLogf(format string, v ...interface{})
- func GetLogger() *log.Logger
- func Info(v ...interface{})
- func Infof(format string, v ...interface{})
- func Infow(msg string, keysAndValues ...interface{})
- func InitCommonLog(clc CommonLogConfig) string
- func InitData(path string, rolling rolling.RollingFormat) error
- func InitDataWithKey(path string, rolling rolling.RollingFormat, task string) error
- func MilliSecondTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
- func NewConsoleEncoder(cfg *zapcore.EncoderConfig) zapcore.Encoder
- func NewTimeEncoder(timeFormat string) func(time.Time, zapcore.PrimitiveArrayEncoder)
- func OpenCommonLog()
- func RegisteCtx(cb contextFunc)
- func SetLevelByString(level string)
- func SetOutputByName(path string)
- func SetOutputPath(dir string)
- func SetRotateByDay()
- func SetRotateByHour()
- func SlowLog(v ...interface{})
- func SlowLogf(format string, v ...interface{})
- func Sync()
- func Warn(v ...interface{})
- func Warnf(format string, v ...interface{})
- func Warning(v ...interface{})
- func Warningf(format string, v ...interface{})
- func Warningw(msg string, keysAndValues ...interface{})
- func Warnw(msg string, keysAndValues ...interface{})
- type CommonLogConfig
- type Logger
- func DataWith(args ...interface{}) *Logger
- func For(ctx context.Context, args ...interface{}) *Logger
- func Log(name string) *Logger
- func New() *Logger
- func NewJSON(path string, r rolling.RollingFormat) (*Logger, error)
- func NewLogger(opt *Options, paths ...string) *Logger
- func With(args ...interface{}) *Logger
- func (l *Logger) GetOutput() io.Writer
- func (l *Logger) Logger() *log.Logger
- func (l *Logger) SetColors(color bool)
- func (l *Logger) SetFlags(flags int)
- func (l *Logger) SetHighlighting(highlighting bool)
- func (l *Logger) SetLevel(level int)
- func (l *Logger) SetLevelByString(level string)
- func (l *Logger) SetLogPrefix(prefix string)
- func (l *Logger) SetOutput(out io.Writer)
- func (l *Logger) SetOutputByName(path string) error
- func (l *Logger) SetOutputPath(path string) error
- func (l *Logger) SetPrintLevel(printLevel bool)
- func (l *Logger) SetRotateByDay()
- func (l *Logger) SetRotateByHour()
- func (l *Logger) SetRotateBySecond()
- func (l *Logger) SetTimeFmt(fmt string) error
- func (l *Logger) With(args ...interface{}) *Logger
- type Options
Constants ¶
View Source
const ( DefaultLoggerName = "_default" SlowLoggerName = "_slow" GenLoggerName = "_gen" CrashLoggerName = "_crash" BalanceLoggerName = "_balance" )
Logger name for default loggers
View Source
const ( TIMENANO = "2006-01-02 15:04:05.9999999" TIMEMICRO = "2006-01-02 15:04:05.999" TIMESECOND = "2006-01-02 15:04:05" DAILY = "20060102" HOURLY = "2006010215" SECONDLY = "200601021505" )
Variables ¶
View Source
var ( DAY_ROTATE = "day" HOUR_ROTATE = "hour" )
Functions ¶
func BalanceLog ¶
func BalanceLog(v ...interface{})
func BalanceLogf ¶
func BalanceLogf(format string, v ...interface{})
func CloseCommonLog ¶
func CloseCommonLog()
func DataLogCtx ¶
func InitCommonLog ¶
func InitCommonLog(clc CommonLogConfig) string
func InitDataWithKey ¶
func InitDataWithKey(path string, rolling rolling.RollingFormat, task string) error
InitData logger
func MilliSecondTimeEncoder ¶
func MilliSecondTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
MilliSecondTimeEncoder 毫秒编码器
func NewConsoleEncoder ¶
func NewConsoleEncoder(cfg *zapcore.EncoderConfig) zapcore.Encoder
func NewTimeEncoder ¶
func NewTimeEncoder(timeFormat string) func(time.Time, zapcore.PrimitiveArrayEncoder)
func OpenCommonLog ¶
func OpenCommonLog()
func RegisteCtx ¶
func RegisteCtx(cb contextFunc)
func SetLevelByString ¶
func SetLevelByString(level string)
func SetOutputByName ¶
func SetOutputByName(path string)
func SetOutputPath ¶
func SetOutputPath(dir string)
func SetRotateByDay ¶
func SetRotateByDay()
func SetRotateByHour ¶
func SetRotateByHour()
Types ¶
type CommonLogConfig ¶
type Logger ¶
type Logger struct { *zap.SugaredLogger // contains filtered or unexported fields }
Logger 日志记录器
func NewJSON ¶
func NewJSON(path string, r rolling.RollingFormat) (*Logger, error)
NewJSON build json data format logger
func (*Logger) SetHighlighting ¶
func (*Logger) SetLevelByString ¶
func (*Logger) SetLogPrefix ¶
func (*Logger) SetOutputByName ¶
func (*Logger) SetOutputPath ¶
func (*Logger) SetPrintLevel ¶
func (*Logger) SetRotateByDay ¶
func (l *Logger) SetRotateByDay()
func (*Logger) SetRotateByHour ¶
func (l *Logger) SetRotateByHour()
func (*Logger) SetRotateBySecond ¶
func (l *Logger) SetRotateBySecond()
func (*Logger) SetTimeFmt ¶
type Options ¶
type Options struct { // There are five logging level // "debug","info","warning","error","fatal", debug is default value Level string Prefix string // Enable logging the full timestamp when a TTY is attached instead of just // the time passed since beginning of execution. DisableFullTimestamp bool // TimesFormat to use for display when a full timestamp is printed TimesFormat string // Whether printf level string when logging or not DisableLevel bool // Force disabling colors. DisableColors bool DisableTimestamp bool // "daily", "hourly", default is not rolling Rolling string // This option will not wrap empty fields in quotes if true DisableQuoteEmptyFields bool // The fields are sorted by default for a consistent output. // Not sorting is default value. Sorting bool }
Click to show internal directories.
Click to hide internal directories.