log

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: GPL-3.0 Imports: 8 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// logger instance used by the application
	Global *logrus.Logger
)

Functions

func NewLogger added in v0.29.0

func NewLogger(logFilename string, logLevel string, logSize int) *logrus.Logger

func SetGlobalLogger added in v0.29.0

func SetGlobalLogger(logFilename string, logLevel string)

func ToLogFile added in v0.29.0

func ToLogFile(filename string) io.Writer

ToLogFile returns an io.Writer to configure WithOutput() option to write to a file and manage log rotation using lumberjack.

func ToNull added in v0.29.0

func ToNull() io.Writer

ToNull returns an io.Writer to configure WithOutput() option to discard all output.

func ToStdOut added in v0.29.0

func ToStdOut() io.Writer

ToStdOut returns an io.Writer to configure WithOutput() option to write to standard out.

Types

type Fields added in v0.29.0

type Fields = logrus.Fields

type FileLogHook added in v0.29.0

type FileLogHook struct {
	Writer    io.Writer
	Formatter logrus.Formatter
}

logrus hook to write log to file

func (*FileLogHook) Fire added in v0.29.0

func (hook *FileLogHook) Fire(entry *logrus.Entry) error

func (*FileLogHook) Levels added in v0.29.0

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

type LogFormat added in v0.29.0

type LogFormat string

type of log format

const (
	JSONFormat LogFormat = "json"
	TextFormat LogFormat = "text"
)

type Logger

type Logger = logrus.Logger

type Options added in v0.29.0

type Options func(*Logger)

Options is a function type that can be used to configure the logger

func WithLevel added in v0.29.0

func WithLevel(level string) Options

WithLevel configures the log level. If level is not specified, default to InfoLevel If level is debug or trace, report caller is enabled

func WithNullLogger added in v0.29.0

func WithNullLogger() Options

WithNullLogger sets the logger to discard all output

func WithOutput added in v0.29.0

func WithOutput(outputs ...io.Writer) Options

WithOutput configures the output destination

Jump to

Keyboard shortcuts

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