log

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Default error tolerance config
	DefaultETConfig ErrorToleranceConfig
	// Default error tolerance logger
	DefaultETLogger *ErrorTolerantLogger
)

Functions

func AddDingTalkAlertHook

func AddDingTalkAlertHook(hookLevels []logrus.Level)

AddDingTalkAlertHook adds logrus hook for DingTalk alert with specified log levels.

func MustInit

func MustInit(conf LoggingConfig)

Init inits logging with specified log level

func MustInitFromViper

func MustInitFromViper()

MustInitFromViper inits logging from viper settings and adapts Geth logger.

Note that viper must be initilized before this, and it will panic and exit if any error happens.

Types

type DingTalkAlertHook

type DingTalkAlertHook struct {
	// contains filtered or unexported fields
}

DingTalkAlertHook logrus hooks to send specified level logs as text message to DingTalk group chat.

func NewDingTalkAlertHook

func NewDingTalkAlertHook(lvls []logrus.Level) *DingTalkAlertHook

NewDingTalkAlertHook constructor to new DingTalkAlertHook instance.

func (*DingTalkAlertHook) Fire

func (hook *DingTalkAlertHook) Fire(logEntry *logrus.Entry) error

Fire implements logrus.Hook interface `Fire` method.

func (*DingTalkAlertHook) Levels

func (hook *DingTalkAlertHook) Levels() []logrus.Level

Levels implements logrus.Hook interface `Levels` method.

type ErrorToleranceConfig added in v0.2.0

type ErrorToleranceConfig struct {
	ReportFailures uint64 `default:"60"`
	RemindFailures uint64 `default:"60"`
}

ErrorToleranceConfig defines the configuration for error tolerance behavior.

type ErrorTolerantLogger added in v0.2.0

type ErrorTolerantLogger struct {
	// contains filtered or unexported fields
}

ErrorTolerantLogger is a thread-safe logger with error tolerance behavior based on the continuous error count.

func MustNewErrorTolerantLoggerFromViper added in v0.2.0

func MustNewErrorTolerantLoggerFromViper() *ErrorTolerantLogger

func NewErrorTolerantLogger added in v0.2.0

func NewErrorTolerantLogger(conf ErrorToleranceConfig) *ErrorTolerantLogger

func (*ErrorTolerantLogger) Log added in v0.2.0

func (etl *ErrorTolerantLogger) Log(l logrus.FieldLogger, err error, msg string)

Log logs the error message with appropriate level based on the continuous error count.

func (*ErrorTolerantLogger) Logf added in v0.2.0

func (etl *ErrorTolerantLogger) Logf(l logrus.FieldLogger, err error, msg string, args ...interface{})

type LoggingConfig

type LoggingConfig struct {
	Level      string `default:"info"` // logging level
	ForceColor bool
}

LoggingConfig logging configuration such as log level etc.,

Jump to

Keyboard shortcuts

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