logger

package
v1.0.92 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEBUG  = 100
	INFO   = 200
	NOTICE = 250
	WARN   = 300
	ERROR  = 400
	PANIC  = 500
	FATAL  = 600
)

Variables

View Source
var (
	Logger = New(log.New(os.Stderr, "", log.Lmsgprefix), "local", DEBUG, "asia/shanghai", datetime.LayoutDateTimeZoneT, nil)
)

Functions

func Debug

func Debug(message string, v ...interface{})

Debug 调试

func Debugf added in v1.0.51

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

Debugf 调试

func Error

func Error(message string, v ...interface{})

Error 错误

func Errorf added in v1.0.51

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

Errorf 错误

func Fatal

func Fatal(message string, v ...interface{})

Fatal 致命错误

func Fatalf added in v1.0.51

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

Fatalf 致命错误

func Info

func Info(message string, v ...interface{})

Info 信息

func Infof added in v1.0.51

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

Infof 信息

func New

func New(raw *log.Logger, env string, level int, timezone, timeFormat string, callback func(log LogEntry)) *logger

func Notice added in v1.0.4

func Notice(message string, v ...interface{})

Notice 通知

func Noticef added in v1.0.51

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

Noticef 通知

func Panic

func Panic(message string, v ...interface{})

Panic 恐慌

func Panicf added in v1.0.51

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

Panicf 恐慌

func SetLevel

func SetLevel(level int)

SetLevel 起始等级

func SetRequest added in v1.0.38

func SetRequest(request *http.Request)

SetRequest 请求

func SetTrace added in v1.0.38

func SetTrace(trace string)

SetTrace 追踪

func Trace added in v1.0.56

func Trace(skip, deep int) []string

Trace 执行链路

func Warn

func Warn(message string, v ...interface{})

Warn 警告

func Warnf added in v1.0.51

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

Warnf 警告

Types

type FeishuAlert added in v1.0.84

type FeishuAlert struct {
	// contains filtered or unexported fields
}
var Feishu *FeishuAlert

func NewFeishu added in v1.0.84

func NewFeishu(options map[string]interface{}) *FeishuAlert

func (*FeishuAlert) Add added in v1.0.84

func (f *FeishuAlert) Add(name string, option Option)

func (*FeishuAlert) AddMap added in v1.0.84

func (f *FeishuAlert) AddMap(name string, setting map[string]interface{})

func (*FeishuAlert) AddMapBatch added in v1.0.84

func (f *FeishuAlert) AddMapBatch(batch map[string]interface{})

func (*FeishuAlert) FindOption added in v1.0.84

func (f *FeishuAlert) FindOption(levelName string, entry, defaultName string) string

func (*FeishuAlert) Format added in v1.0.84

func (f *FeishuAlert) Format(log LogEntry, kibanaUrl, esIndex string) string

func (*FeishuAlert) Send added in v1.0.84

func (f *FeishuAlert) Send(log LogEntry)

type LogEntry added in v1.0.82

type LogEntry struct {
	Datetime  string      `json:"datetime"`
	Env       string      `json:"env"`
	Channel   string      `json:"channel"`
	Level     int         `json:"level"`
	LevelName string      `json:"level_name"`
	Trace     string      `json:"trace"`
	IP        string      `json:"ip"`
	Command   string      `json:"command"`
	Message   string      `json:"message"`
	Context   string      `json:"context"`
	Memory    uint64      `json:"memory"`
	Method    string      `json:"method"`
	URL       string      `json:"url"`
	UserAgent string      `json:"ua"`
	Referer   string      `json:"referer"`
	Extra     interface{} `json:"extra,omitempty"`
}

type Option added in v1.0.84

type Option struct {
	Levels    []string `json:"levels"`
	Webhook   string   `json:"webhook"`
	SignKey   string   `json:"sign_key"`
	UserId    string   `json:"user_id"`
	KibanaUrl string   `json:"kibana_url"`
	EsIndex   string   `json:"es_index"`
}

Jump to

Keyboard shortcuts

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