cLog

package module
v0.4.20 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2025 License: MIT Imports: 16 Imported by: 20

Documentation

Index

Constants

View Source
const (
	LogConfigName = "LogConf"

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

	LOG_FORMAT_JSON LogFormat = "json"
	LOG_FORMAT_TEXT LogFormat = "text"

	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 WithContext added in v0.0.8

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

Types

type CallerSkip added in v0.4.14

type CallerSkip int

func (CallerSkip) Value added in v0.4.20

func (i CallerSkip) Value() any

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 ExcludePaths added in v0.4.19

type ExcludePaths []string

func (ExcludePaths) Value added in v0.4.20

func (i ExcludePaths) Value() any

type FileHook added in v0.4.0

type FileHook struct {
	Path     string            `json:"path"`
	Format   LogFormat         `json:"format"`
	Rotation FileHook_Rotation `json:"rotation"`
}

func (FileHook) Fire added in v0.4.0

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

func (FileHook) GetColorful added in v0.4.3

func (e FileHook) GetColorful() bool

func (FileHook) GetFormat added in v0.4.3

func (e FileHook) GetFormat() LogFormat

func (FileHook) Levels added in v0.4.0

func (e FileHook) Levels() []logrus.Level

type FileHook_Rotation added in v0.4.3

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

type FormatterInterface added in v0.4.3

type FormatterInterface interface {
	GetFormat() LogFormat
	GetColorful() bool
}

type IncludePaths added in v0.4.19

type IncludePaths []string

func (IncludePaths) Value added in v0.4.20

func (i IncludePaths) Value() any

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   FileHook   `json:"file"`
	Loki   LokiHook   `json:"loki"`
	Stdout StdoutHook `json:"stdout"`
}

type LogDriver added in v0.0.52

type LogDriver string

type LogFormat added in v0.4.3

type LogFormat string

type LokiHook added in v0.0.52

type LokiHook struct {
	Host         string `json:"host"`
	Uri          string `json:"uri"`
	QueueMaxSize int    `json:"queue_max_size"`
	QueueSpeed   int    `json:"queue_speed"`
	Timeout      int64  `json:"timeout"`
	Interval     int64  `json:"interval"`
	// contains filtered or unexported fields
}

func (LokiHook) Consume added in v0.4.3

func (e LokiHook) Consume()

func (LokiHook) Fire added in v0.0.52

func (e LokiHook) Fire(entry *logrus.Entry) (err error)

func (LokiHook) GetColorful added in v0.4.3

func (e LokiHook) GetColorful() bool

func (LokiHook) GetFormat added in v0.4.3

func (e LokiHook) GetFormat() LogFormat

func (LokiHook) Levels added in v0.0.52

func (e 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 Option added in v0.4.15

type Option interface {
	Value() any
}

type RotationType added in v0.0.52

type RotationType string

type StdoutHook added in v0.4.0

type StdoutHook struct {
	Format   LogFormat `json:"format"`
	Colorful bool      `json:"colorful"`
}

func (StdoutHook) Fire added in v0.4.0

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

func (StdoutHook) GetColorful added in v0.4.3

func (e StdoutHook) GetColorful() bool

func (StdoutHook) GetFormat added in v0.4.3

func (e StdoutHook) GetFormat() LogFormat

func (StdoutHook) Levels added in v0.4.0

func (e StdoutHook) Levels() []logrus.Level

Jump to

Keyboard shortcuts

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