logging

package
v0.0.0-...-7429660 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2023 License: Apache-2.0 Imports: 24 Imported by: 4

Documentation

Index

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 CrashLog

func CrashLog(v ...interface{})

func CrashLogf

func CrashLogf(format string, v ...interface{})

func DataLog

func DataLog(topic string, keysAndValues ...interface{})

func DataLogCtx

func DataLogCtx(ctx context.Context, topic string, keysAndValues ...interface{})

func Debug

func Debug(v ...interface{})

func Debugf

func Debugf(format string, v ...interface{})

func Debugw

func Debugw(msg string, keysAndValues ...interface{})

func Error

func Error(v ...interface{})

func Errorf

func Errorf(format string, v ...interface{})

func Errorw

func Errorw(msg string, keysAndValues ...interface{})

func Fatal

func Fatal(v ...interface{})

func Fatalf

func Fatalf(format string, v ...interface{})

func GenLog

func GenLog(v ...interface{})

func GenLogf

func GenLogf(format string, v ...interface{})

func GetLogger

func GetLogger() *log.Logger

func Info

func Info(v ...interface{})

func Infof

func Infof(format string, v ...interface{})

func Infow

func Infow(msg string, keysAndValues ...interface{})

func InitCommonLog

func InitCommonLog(clc CommonLogConfig) string

func InitData

func InitData(path string, rolling rolling.RollingFormat) error

InitData logger

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()

func SlowLog

func SlowLog(v ...interface{})

func SlowLogf

func SlowLogf(format string, v ...interface{})

func Sync

func Sync()

Sync all log data

func Warn

func Warn(v ...interface{})

func Warnf

func Warnf(format string, v ...interface{})

func Warning

func Warning(v ...interface{})

func Warningf

func Warningf(format string, v ...interface{})

func Warningw

func Warningw(msg string, keysAndValues ...interface{})

func Warnw

func Warnw(msg string, keysAndValues ...interface{})

Types

type CommonLogConfig

type CommonLogConfig struct {
	Pathprefix      string
	Rotate          string
	GenLogLevel     string
	BalanceLogLevel string
}

type Logger

type Logger struct {
	*zap.SugaredLogger
	// contains filtered or unexported fields
}

Logger 日志记录器

func DataWith

func DataWith(args ...interface{}) *Logger

func For

func For(ctx context.Context, args ...interface{}) *Logger

func Log

func Log(name string) *Logger

func New

func New() *Logger

func NewJSON

func NewJSON(path string, r rolling.RollingFormat) (*Logger, error)

NewJSON build json data format logger

func NewLogger

func NewLogger(opt *Options, paths ...string) *Logger

func With

func With(args ...interface{}) *Logger

func (*Logger) GetOutput

func (l *Logger) GetOutput() io.Writer

func (*Logger) Logger

func (l *Logger) Logger() *log.Logger

func (*Logger) SetColors

func (l *Logger) SetColors(color bool)

func (*Logger) SetFlags

func (l *Logger) SetFlags(flags int)

func (*Logger) SetHighlighting

func (l *Logger) SetHighlighting(highlighting bool)

func (*Logger) SetLevel

func (l *Logger) SetLevel(level int)

func (*Logger) SetLevelByString

func (l *Logger) SetLevelByString(level string)

func (*Logger) SetLogPrefix

func (l *Logger) SetLogPrefix(prefix string)

func (*Logger) SetOutput

func (l *Logger) SetOutput(out io.Writer)

func (*Logger) SetOutputByName

func (l *Logger) SetOutputByName(path string) error

func (*Logger) SetOutputPath

func (l *Logger) SetOutputPath(path string) error

func (*Logger) SetPrintLevel

func (l *Logger) SetPrintLevel(printLevel bool)

func (*Logger) SetRotateByDay

func (l *Logger) SetRotateByDay()

func (*Logger) SetRotateByHour

func (l *Logger) SetRotateByHour()

func (*Logger) SetRotateBySecond

func (l *Logger) SetRotateBySecond()

func (*Logger) SetTimeFmt

func (l *Logger) SetTimeFmt(fmt string) error

func (*Logger) With

func (l *Logger) With(args ...interface{}) *Logger

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
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL