logger

package
v1.15.2 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: Apache-2.0 Imports: 16 Imported by: 45

Documentation

Index

Constants

View Source
const (

	// 时间戳 - 毫秒
	Timestamp = "2006-01-02T15:04:05.000"
)

日志默认以天为单位

Variables

This section is empty.

Functions

func Debug

func Debug(v ...interface{})

func Debugf

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

func Error

func Error(v ...interface{})

func Errorf

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

func Fatal

func Fatal(v ...interface{})

func Fatalf

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

func FlushLogger

func FlushLogger()

func Info

func Info(v ...interface{})

func Infof

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

func InitLogger

func InitLogger(path string, level ...LogLevel)

InitLogger 初始化

func IsDebug

func IsDebug() bool

IsDebug 是否DEBUG模式

func SetLevel

func SetLevel(level LogLevel)

func SetLogPath deprecated

func SetLogPath(path string)

SetLogPath 设置日志路径, 默认是INFO级别日志

Deprecated: 推荐使用 InitLogger

func Warn

func Warn(v ...interface{})

func Warnf

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

Types

type ConsoleWriter

type ConsoleWriter struct {
}

func (*ConsoleWriter) NeedPrefix

func (w *ConsoleWriter) NeedPrefix() bool

func (*ConsoleWriter) Write

func (w *ConsoleWriter) Write(v []byte)

type DateType

type DateType uint8
const (
	DAY DateType = iota
	HOUR
)

type DateWriter

type DateWriter struct {
	// contains filtered or unexported fields
}

func NewDateWriter

func NewDateWriter(logpath, name string, dateType DateType, num int) *DateWriter

func (*DateWriter) NeedPrefix

func (w *DateWriter) NeedPrefix() bool

func (*DateWriter) Write

func (w *DateWriter) Write(v []byte)

type HourWriter

type HourWriter struct {
}

type LogLevel

type LogLevel uint8
const (
	DEBUG LogLevel = iota
	INFO
	WARN
	ERROR
	OFF
	FATAL
)

func StringToLevel

func StringToLevel(level string) LogLevel

func (*LogLevel) String

func (lv *LogLevel) String() string

type LogWriter

type LogWriter interface {
	Write(v []byte)
	NeedPrefix() bool
}

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

func GetLogger

func GetLogger(name string) *Logger

GetLogger return an logger instance

func (*Logger) Debug

func (l *Logger) Debug(v ...interface{})

func (*Logger) Debugf

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

func (*Logger) Error

func (l *Logger) Error(v ...interface{})

func (*Logger) Errorf

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

func (*Logger) Fatal

func (l *Logger) Fatal(v ...interface{})

func (*Logger) Fatalf

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

func (*Logger) Info

func (l *Logger) Info(v ...interface{})

func (*Logger) Infof

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

func (*Logger) IsConsoleWriter

func (l *Logger) IsConsoleWriter() bool

func (*Logger) SetConsole

func (l *Logger) SetConsole()

func (*Logger) SetDayRoller

func (l *Logger) SetDayRoller(logpath string, num int) error

func (*Logger) SetFileRoller

func (l *Logger) SetFileRoller(logpath string, num int, sizeMB int) error

func (*Logger) SetHourRoller

func (l *Logger) SetHourRoller(logpath string, num int) error

func (*Logger) SetLogName

func (l *Logger) SetLogName(name string)

func (*Logger) SetWriter

func (l *Logger) SetWriter(w LogWriter)

func (*Logger) Warn

func (l *Logger) Warn(v ...interface{})

func (*Logger) Warnf

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

type RollFileWriter

type RollFileWriter struct {
	// contains filtered or unexported fields
}

func NewRollFileWriter

func NewRollFileWriter(logpath, name string, num, sizeMB int) *RollFileWriter

func (*RollFileWriter) NeedPrefix

func (w *RollFileWriter) NeedPrefix() bool

func (*RollFileWriter) Write

func (w *RollFileWriter) Write(v []byte)

Jump to

Keyboard shortcuts

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