logger

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 2, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LevelDebug = iota
	LevelInfo
	LevelWarn
	LevelError
)
View Source
const (
	DefaultKeyDebug = "debug"
	DefaultKeyInfo  = "info"
	DefaultKeyWarn  = "warn"
	DefaultKeyError = "error"
)
View Source
const DefaultChannelCache = 10
View Source
const DefaultMapKey = "default"
View Source
const DefaultPath = "./logs"
View Source
const (
	MillTimeFormat = "2006-01-02 15:04:05.000"
)

Variables

This section is empty.

Functions

func Debug

func Debug(msg string, args ...interface{})

func DebugByName

func DebugByName(name, msg string, args ...interface{})

func Error

func Error(msg string, args ...interface{})

func ErrorByName

func ErrorByName(name, msg string, args ...interface{})

func Info

func Info(msg string, args ...interface{})

func InfoByName

func InfoByName(name, msg string, args ...interface{})

func Warn

func Warn(msg string, args ...interface{})

func WarnByName

func WarnByName(name, msg string, args ...interface{})

Types

type LogConfig

type LogConfig struct {
	Path       string `json:"path"`
	Name       string `json:"name"`
	Level      int    `json:"level"`
	Override   bool   `json:"override"`
	ToConsole  bool   `json:"toConsole"`
	Split2Day  bool   `json:"split2Day"`  // 是否需要拆分成按日期分的不同文件
	SimpleFile bool   `json:"simpleFile"` // true 所有日志都写入单个文件, false 日志按等级拆分成多个文件
	ShowStack  bool   `json:"showStack"`  // 当错误时是否显示stack
}

func NewLogConfig

func NewLogConfig() *LogConfig

func NewLoggerConfByPath

func NewLoggerConfByPath(path string) *LogConfig

func NewLoggerConfByPathAndName

func NewLoggerConfByPathAndName(path, name string) *LogConfig

func (*LogConfig) Clone

func (l *LogConfig) Clone() *LogConfig

type LogMessage

type LogMessage struct {
	Msg   string
	Level int
}

type Logger

type Logger struct {
	Key        string             // the key of map
	Ctx        context.Context    // the context of log
	CancelFunc context.CancelFunc // the func of cancel logger

	Channel chan LogMessage // the input chan
	Conf    *LogConfig
	// contains filtered or unexported fields
}

func NewLogger

func NewLogger(conf *LogConfig) *Logger

func (*Logger) Debug

func (obj *Logger) Debug(msg string, args ...interface{})

func (*Logger) Destroy

func (obj *Logger) Destroy()

func (*Logger) Error

func (obj *Logger) Error(msg string, args ...interface{})

func (*Logger) Info

func (obj *Logger) Info(msg string, args ...interface{})

func (*Logger) Warn

func (obj *Logger) Warn(msg string, args ...interface{})

Jump to

Keyboard shortcuts

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