logging

package
v0.0.0-...-3b62c27 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

func Copy() *logrus.Logger

Copy returns a copy of the logrus standar logger

func NewLogCmd

func NewLogCmd(logfile *lumberjack.Logger) *cobra.Command

NewLogCmd creates a new log command from a log file

func NewLogFileHook

func NewLogFileHook(file io.Writer, formatter log.Formatter) log.Hook

NewLogFileHook will create a logrus hook that logs to a log file for all logging levels

Types

type Hook

type Hook struct {
	Writer    io.Writer
	LogLevels []log.Level
}

Hook is a generic logging hook... Stolen from the logrus

func (*Hook) Fire

func (hook *Hook) Fire(entry *log.Entry) error

Fire will be called when some logging function is called with current hook It will format log entry to string and write it to appropriate writer

func (*Hook) Levels

func (hook *Hook) Levels() []log.Level

Levels define on which log levels this hook would trigger

type Logger

type Logger interface {
	Errorf(string, ...interface{})
	Warningf(string, ...interface{})
	Infof(string, ...interface{})
	Debugf(string, ...interface{})
}

Logger is a basic logger

var Discard Logger = &discardLogger{}

Discard an logs sent to this logger

func NewMaybeLogger

func NewMaybeLogger(log Logger) Logger

NewMaybeLogger creates a new logger from an existing one that can safely be nil without panicing

type MaybeLogger

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

MaybeLogger is a logger that can hold a nil logger internally

func (*MaybeLogger) Debugf

func (ml *MaybeLogger) Debugf(s string, v ...interface{})

Debugf reports debugging info

func (*MaybeLogger) Errorf

func (ml *MaybeLogger) Errorf(s string, v ...interface{})

Errorf reports an error

func (*MaybeLogger) Infof

func (ml *MaybeLogger) Infof(s string, v ...interface{})

Infof reports info

func (*MaybeLogger) Warningf

func (ml *MaybeLogger) Warningf(s string, v ...interface{})

Warningf reports a warning

type PrefixedFormatter

type PrefixedFormatter struct {
	Prefix     string
	TimeFormat string
}

PrefixedFormatter is a logging text formatter that logs with a prefix

func (*PrefixedFormatter) Format

func (pf *PrefixedFormatter) Format(e *logrus.Entry) ([]byte, error)

Format using the prefixed formatter

type SilentFormatter

type SilentFormatter struct{}

SilentFormatter is a logrus formatter that does nothing

func (*SilentFormatter) Format

func (sf *SilentFormatter) Format(*logrus.Entry) ([]byte, error)

Format does nothing

Jump to

Keyboard shortcuts

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