logger

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEBUG = iota
	INFO
	WARN
	ERROR
)
View Source
const (
	DefaultFileMaxSize = 10485760
	LogInfoChanSize    = 1000
	MaxWriteCacheNum   = 1000
)

Variables

View Source
var (
	LeftBracket  = []byte("[")
	RightBracket = []byte("]")
	Space        = []byte(" ")
	Colon        = []byte(":")
	FuncBracket  = []byte("()")
	LineFeed     = []byte("\n")
)
View Source
var (
	RED     = []byte{27, 91, 51, 49, 109}
	GREEN   = []byte{27, 91, 51, 50, 109}
	YELLOW  = []byte{27, 91, 51, 51, 109}
	BLUE    = []byte{27, 91, 51, 52, 109}
	MAGENTA = []byte{27, 91, 51, 53, 109}
	CYAN    = []byte{27, 91, 51, 54, 109}
	WHITE   = []byte{27, 91, 51, 55, 109}
	RESET   = []byte{27, 91, 48, 109}
)
View Source
var LevelMap = map[int][]byte{
	DEBUG: []byte("DEBUG"),
	INFO:  []byte("INFO"),
	WARN:  []byte("WARN"),
	ERROR: []byte("ERROR"),
}

Functions

func CloseLogger

func CloseLogger()

func Debug

func Debug(msg string, param ...any)

func Error

func Error(msg string, param ...any)

func Info

func Info(msg string, param ...any)

func InitLogger

func InitLogger(appName, logLevel string)

func Stack

func Stack() string

func StackAll

func StackAll() string

func Warn

func Warn(msg string, param ...any)

Types

type LogInfo

type LogInfo struct {
	Time        time.Time
	Level       int
	Msg         *[]byte
	FileName    string
	FuncName    string
	Line        int
	GoroutineId string
	ThreadId    string
}

type Logger

type Logger struct {
	AppName       string
	Level         int
	TrackLine     bool
	TrackThread   bool
	EnableFile    bool
	FileMaxSize   int32
	DisableColor  bool
	EnableJson    bool
	File          *os.File
	LogInfoChan   chan *LogInfo
	WriteBuf      []byte
	WriteCacheNum int32
	CloseChan     chan struct{}
}
var LOG *Logger = nil

Jump to

Keyboard shortcuts

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