Documentation ¶
Index ¶
- Variables
- func BindFlags(cmd *cobra.Command)
- func MustInit(conf LoggingConfig)
- func MustInitFromViper()
- func MustInitWithCtx(ctx context.Context, wg *sync.WaitGroup, conf LoggingConfig)
- func MustInitWithCtxFromViper(ctx context.Context, wg *sync.WaitGroup)
- type ErrorToleranceConfig
- type ErrorTolerantLogger
- type LoggingConfig
Constants ¶
This section is empty.
Variables ¶
var ( // Default error tolerance config DefaultETConfig ErrorToleranceConfig // Default error tolerance logger DefaultETLogger *ErrorTolerantLogger )
Functions ¶
func MustInit ¶
func MustInit(conf LoggingConfig)
MustInit sets up the logging system according to the provided LoggingConfig and log level. It configures the log level, adds an alert hook, sets a text formatter, and adapts the logger for Geth compatibility. In case of any error during initialization, this function will panic.
func MustInitFromViper ¶
func MustInitFromViper()
MustInitFromViper initializes the logging system using configurations from viper.
Precondition:
- Viper must be initialized with appropriate configurations before calling this function.
Panics:
- This function will panic if it encounters any errors during initialization.
func MustInitWithCtx ¶ added in v0.2.1
func MustInitWithCtx(ctx context.Context, wg *sync.WaitGroup, conf LoggingConfig)
MustInitWithCtx performs the similiar initializations as `MustInit` with support for graceful shutdown by accepting a context and a wait group.
func MustInitWithCtxFromViper ¶ added in v0.2.1
MustInitWithCtxFromViper performs the similar initializations as `MustInitFromViper` with support for graceful shutdown by accepting a context and a wait group.
Parameters:
- ctx: The context for graceful shutdown handling.
- wg: The wait group to track goroutines for shutdown synchronization.
Types ¶
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 // helpful on windows DisableColor bool // helpful to output logs in file AlertHook hook.Config // alert hooking configurations }
LoggingConfig logging configuration such as log level etc.,