cLog

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: MIT Imports: 14 Imported by: 16

Documentation

Index

Constants

View Source
const (
	LogConfigName = "LogConf"

	LOG_DRIVER_STDOUT LogDriver = "stdout"
	LOG_DRIVER_FILE   LogDriver = "file"
	LOG_DRIVER_LOKI   LogDriver = "loki"

	ROTATION_TYPE_MINUTE RotationType = "minute"
	ROTATION_TYPE_HOUR   RotationType = "hour"
	ROTATION_TYPE_DAY    RotationType = "day"
	ROTATION_TYPE_MONTH  RotationType = "month"
	ROTATION_TYPE_YEAR   RotationType = "year"

	LOG_FIELD_LEVEL    string = "level"
	LOG_FIELD_PARAMS   string = "params"
	LOG_FIELD_MESSAGE  string = "message"
	LOG_FIELD_DATETIME string = "datetime"
	LOG_FIELD_REPORTER string = "reporter"
)
View Source
const (
	PanicLevel logrus.Level = iota
	FatalLevel
	ErrorLevel
	WarnLevel
	InfoLevel
	DebugLevel
	TraceLevel
)

Variables

View Source
var Component = &LogComponent{}

Functions

func Level added in v0.0.52

func Level(level logrus.Level)

func SetCallerSkip added in v0.4.0

func SetCallerSkip(skip int)

func WithContext added in v0.0.8

func WithContext(ctx *gin.Context, params map[string]any) *logrus.Entry

Types

type EmptyWriter added in v0.4.0

type EmptyWriter struct{}

func NewEmptyWriter added in v0.4.0

func NewEmptyWriter() *EmptyWriter

func (EmptyWriter) Write added in v0.4.0

func (e EmptyWriter) Write(p []byte) (n int, err error)

type FileHook added in v0.4.0

type FileHook struct{}

func NewFileHook added in v0.4.0

func NewFileHook() *FileHook

func (*FileHook) Fire added in v0.4.0

func (i *FileHook) Fire(entry *logrus.Entry) error

func (*FileHook) Levels added in v0.4.0

func (i *FileHook) Levels() []logrus.Level

type LogComponent added in v0.4.0

type LogComponent struct{}

func (*LogComponent) Inject added in v0.4.0

func (i *LogComponent) Inject(instance any) bool

func (*LogComponent) InjectConf added in v0.4.0

func (i *LogComponent) InjectConf(config cComponents.ConfigInterface) bool

func (*LogComponent) Listen added in v0.4.0

func (i *LogComponent) Listen() []*cComponents.ConfigListener

func (*LogComponent) Load added in v0.4.0

func (i *LogComponent) Load()

type LogConf

type LogConf struct {
	Level      logrus.Level     `json:"level"`
	Drivers    []LogDriver      `json:"drivers"`
	WithFields map[string]any   `json:"with_fields"`
	Excludes   []string         `json:"excludes"`
	Clients    *LogConf_Clients `json:"clients"`
}

func (*LogConf) ConfigName

func (i *LogConf) ConfigName() string

type LogConf_Clients added in v0.0.52

type LogConf_Clients struct {
	File *LogConf_FileClient `json:"file"`
	Loki *LogConf_LokiClient `json:"loki"`
}

type LogConf_FileClient added in v0.0.52

type LogConf_FileClient struct {
	Path     string                       `json:"path"`
	Rotation *LogConf_FileClient_Rotation `json:"rotation"`
}

type LogConf_FileClient_Rotation added in v0.0.52

type LogConf_FileClient_Rotation struct {
	Enable  bool         `json:"enable"`
	Type    RotationType `json:"type"`
	MaxFile int64        `json:"max_file"`
	MaxSize int64        `json:"max_size"`
}

type LogConf_LokiClient added in v0.0.52

type LogConf_LokiClient struct {
	Host         string `json:"host"`
	Uri          string `json:"uri"`
	QueueMaxSize int    `json:"queue_max_size"`
	QueueSpeed   int    `json:"queue_speed"`
	Timeout      int    `json:"timeout"`
	Interval     int    `json:"interval"`
}

type LogDriver added in v0.0.52

type LogDriver string

type LokiHook added in v0.0.52

type LokiHook struct {
	Host     string
	Uri      string
	Queue    []*logrus.Entry
	MaxSize  int
	Speed    int
	Timeout  int64
	Interval int64
}

func NewLokiHook added in v0.4.0

func NewLokiHook() *LokiHook

func (*LokiHook) Fire added in v0.0.52

func (i *LokiHook) Fire(entry *logrus.Entry) error

func (*LokiHook) Levels added in v0.0.52

func (i *LokiHook) Levels() []logrus.Level

type LokiReq added in v0.0.52

type LokiReq struct {
	Streams []*LokiReq_Stream `json:"streams"`
}

type LokiReq_Stream added in v0.0.52

type LokiReq_Stream struct {
	Stream map[string]string `json:"stream"`
	Values [][2]string       `json:"values"`
}

type RotationType added in v0.0.52

type RotationType string

type StdoutHook added in v0.4.0

type StdoutHook struct{}

func NewStdoutHook added in v0.4.0

func NewStdoutHook() *StdoutHook

func (*StdoutHook) Fire added in v0.4.0

func (i *StdoutHook) Fire(entry *logrus.Entry) error

func (*StdoutHook) Levels added in v0.4.0

func (i *StdoutHook) Levels() []logrus.Level

Jump to

Keyboard shortcuts

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