logger

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const LogLevelKey = "log-level"

LogLevelKey identifies the log-level type.

Variables

This section is empty.

Functions

func ConfigureLogger

func ConfigureLogger() error

ConfigureLogger sets up both the logging framework native to this application as well to used libraries.

Types

type Formatter

type Formatter struct {
	// FieldsOrder - default: fields sorted alphabetically
	FieldsOrder []string

	// TimestampFormat - default: time.StampMilli = "Jan _2 15:04:05.000"
	TimestampFormat string

	// HideKeys - show [fieldValue] instead of [fieldKey:fieldValue]
	HideKeys bool

	// NoColors - disable colors
	NoColors bool

	// NoFieldsColors - apply colors only to the level, default is level + fields
	NoFieldsColors bool

	// NoFieldsSpace - no space between fields
	NoFieldsSpace bool

	// ShowFullLevel - show a full level [WARNING] instead of [WARN]
	ShowFullLevel bool

	// NoUppercaseLevel - no upper case for level value
	NoUppercaseLevel bool

	// TrimMessages - trim whitespaces on messages
	TrimMessages bool

	// CallerFirst - print caller info first
	CallerFirst bool

	// CustomCallerFormatter - set custom formatter for caller info
	CustomCallerFormatter func(*runtime.Frame) string
}

Formatter - logrus formatter, implements logrus.Formatter

func (*Formatter) Format

func (f *Formatter) Format(entry *logrus.Entry) ([]byte, error)

Format an log entry

type LogLevel

type LogLevel string

LogLevel implements a CLI flag.

const (
	LogLevelError LogLevel = "error"
	LogLevelWarn  LogLevel = "warn"
	LogLevelInfo  LogLevel = "info"
	LogLevelDebug LogLevel = "debug"
)

CLI log level strings

func (*LogLevel) Set

func (ll *LogLevel) Set(v string) error

Set stores the given flag value.

func (*LogLevel) String

func (ll *LogLevel) String() string

String returns the string value of a log level flag.

func (*LogLevel) Type

func (ll *LogLevel) Type() string

Type returns the type of the CLI flag

type NamedLogger

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

NamedLogger provides log facilities that can be replaced during runtime.

func GetInstance

func GetInstance() *NamedLogger

GetInstance returns a configured logger.

func (*NamedLogger) Debug

func (ll *NamedLogger) Debug(args ...interface{})

Debug logs a message with debug level.

func (*NamedLogger) Debugf

func (ll *NamedLogger) Debugf(format string, args ...interface{})

Debugf logs a printf-style message with debug level.

func (*NamedLogger) Error

func (ll *NamedLogger) Error(args ...interface{})

Error logs a message with error level.

func (*NamedLogger) Errorf

func (ll *NamedLogger) Errorf(format string, args ...interface{})

Errorf logs a printf-style message with error level.

func (*NamedLogger) Info

func (ll *NamedLogger) Info(args ...interface{})

Info logs a message with info level.

func (*NamedLogger) Infof

func (ll *NamedLogger) Infof(format string, args ...interface{})

Infof logs a printf-style message with info level.

func (*NamedLogger) Warning

func (ll *NamedLogger) Warning(args ...interface{})

Warning logs a message with warn level.

func (*NamedLogger) Warningf

func (ll *NamedLogger) Warningf(format string, args ...interface{})

Warningf logs a printf-style message with warn level.

Jump to

Keyboard shortcuts

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