logging

package
v0.0.0-...-9b1755c Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2021 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

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"
)
View Source
const (
	MonthlyRolling  RollingFormat = "200601"
	DailyRolling                  = "20060102"
	HourlyRolling                 = "2006010215"
	MinutelyRolling               = "200601021504"
	SecondlyRolling               = "20060102150405"
)
View Source
const (
	DefaultLoggerName = "_default"
)

Logger name for default loggers

Variables

View Source
var ErrClosedRollingFile = errors.New("rolling file is closed")

Functions

func DataLog

func DataLog(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 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 InitData

func InitData(path string, rolling RollingFormat) error

InitData logger

func InitDataWithKey

func InitDataWithKey(path string, rolling RollingFormat, task string) error

InitDataWithKey logger

func MilliSecondTimeEncoder

func MilliSecondTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)

func NewConsoleEncoder

func NewConsoleEncoder(cfg *zapcore.EncoderConfig) zapcore.Encoder

func NewRollingFile

func NewRollingFile(basePath string, rolling RollingFormat) (*rollingFile, error)

func NewTimeEncoder

func NewTimeEncoder(timeFormat string) func(time.Time, zapcore.PrimitiveArrayEncoder)

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 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 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 GetMyLogger

func GetMyLogger(name string) *Logger

func Log

func Log(name string) *Logger

func New

func New() *Logger

func NewJSON

func NewJSON(path string, 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

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
}

type RollingFormat

type RollingFormat string

Jump to

Keyboard shortcuts

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