logging

package
v0.0.0-...-6d2f78d Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package logging provides a logrus logging implementation. Configuration is determined via environment variables upon startup and logging level may be changed at runtime.

Index

Constants

View Source
const (
	DebugLevel   = "debug"
	InfoLevel    = "info"
	WarningLevel = "warning"
	ErrorLevel   = "error"
	FatalLevel   = "fatal"
	PanicLevel   = "panic"
)

Logging level strings.

View Source
const (
	DebugColor   = 10170623
	InfoColor    = 3581519
	WarningColor = 14327864
	ErrorColor   = 13631488
	PanicColor   = 13631488
	FatalColor   = 13631488
)

Logging level color constants.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

type Interface interface {
	logrus.FieldLogger
	WrappedLogger() *logrus.Logger
	UpdateLevel(level string)
	UpdateDiscordrus()
	DiscordGoLogf(discordgoLevel, caller int, format string, arguments ...interface{})
}

Interface wraps the logrus.FieldLogger interface and includes custom methods.

type Locale

type Locale struct {
	*time.Location
	logrus.Formatter
}

Locale is used for formatting logs for a locale.

func (*Locale) Format

func (locale *Locale) Format(log *logrus.Entry) ([]byte, error)

Format satisfies the logrus.Formatter interface.

type Logger

type Logger struct {
	*logrus.Entry
	Location             *time.Location
	DiscordrusWebHookURL string
	// contains filtered or unexported fields
}

Logger wraps a *logrus.Logger instance and provides custom methods.

func New

func New(options ...OptionFunc) *Logger

New returns a new *Logger instance configured with the OptionFunc arguments provided.

func (*Logger) DiscordGoLogf

func (logger *Logger) DiscordGoLogf(discordgoLevel, _ int, format string, arguments ...interface{})

DiscordGoLogf is an adapter for plugging into DiscordGo's logging system.

func (*Logger) UpdateDiscordrus

func (logger *Logger) UpdateDiscordrus()

UpdateDiscordrus updates the Discordrus integration to use the *Logger configuration.

func (*Logger) UpdateLevel

func (logger *Logger) UpdateLevel(level string)

UpdateLevel allows for runtime updates of the logging level.

func (*Logger) WrappedLogger

func (logger *Logger) WrappedLogger() *logrus.Logger

WrappedLogger returns the wrapped *logrus.Logger instance.

type OptionFunc

type OptionFunc func(*Logger)

OptionFunc is used to configure options for a *Logger.

func OptionalDiscordrus

func OptionalDiscordrus(webhookURL string) OptionFunc

OptionalDiscordrus returns an OptionFunc to configure a *Logger to use a Discordrus webhook URL.

func OptionalLogLevel

func OptionalLogLevel(logLevel string) OptionFunc

OptionalLogLevel returns an OptionFunc to configure a *Logger log level.

func OptionalOutput

func OptionalOutput(output io.Writer) OptionFunc

OptionalOutput returns an OptionFunc to configure a *Logger to set where log messages should output to.

func OptionalShardID

func OptionalShardID(shardID int) OptionFunc

OptionalShardID returns an OptionFunc to configure a *Logger to include a shardID field.

func OptionalTimezoneLocation

func OptionalTimezoneLocation(timezoneLocation string) OptionFunc

OptionalTimezoneLocation returns an OptionFunc to configure a *Logger timezone location.

Jump to

Keyboard shortcuts

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