logger

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(args ...interface{})

Debug logs a message at level Debug to stdout.

func Debugf

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

Debugf formats according to a format specifier and logs message at level Debug to stdout.

func Error

func Error(args ...interface{})

Error logs a message at level Error to stderr.

func Errorf

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

Errorf logs a formatted message at level Error to stderr.

func Fatal

func Fatal(args ...interface{})

Fatal logs a message at level Fatal to stderr then the process will exit with status set to 1.

func Fatalf

func Fatalf(format string, args ...interface{})

Fatalf logs a formatted message at level Fatal to stderr then the process will exit with status set to 1.

func Info

func Info(args ...interface{})

Info logs a message at level Info to stdout.

func Infof

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

Infof logs a formatted message at level Info to stdout.

func Output

func Output(args ...interface{})

Output logs a message to stdout without formatting.

func Outputf

func Outputf(format string, args ...interface{})

Outputf formats according to a format specifier and writes to standard output.

func Panic

func Panic(args ...interface{})

Panic logs a message at level Panic to stderr; calls panic() after logging.

func Panicf

func Panicf(format string, args ...interface{})

Panicf logs a formatted message at level Panic to stderr; calls panic() after logging.

func PrintBuffer

func PrintBuffer(buffer *bytes.Buffer, logDebug bool)

PrintBuffer prints from buffer to either Debug or Info

func SetLevelDebug

func SetLevelDebug()

SetLevelDebug sets the standard logger level to Debug

func SetLevelInfo

func SetLevelInfo()

SetLevelInfo sets the standard logger level to Info

func Trace

func Trace(args ...interface{})

Trace logs a message at level Trace to stdout.

func Warn

func Warn(args ...interface{})

Warn logs a message at level Warn to stdout.

func Warnf

func Warnf(format string, args ...interface{})

Warnf logs a formatted message at level Warn to stdout.

Types

type ColorScheme

type ColorScheme struct {
	InfoLevelStyle  string
	WarnLevelStyle  string
	ErrorLevelStyle string
	FatalLevelStyle string
	PanicLevelStyle string
	DebugLevelStyle string
	PrefixStyle     string
	TimestampStyle  string
}

ColorScheme allows changing of level colors

type TextFormatter

type TextFormatter struct {
	// Set to true to bypass checking for a TTY before outputting colors.
	ForceColors bool

	// Force disabling colors. For a TTY colors are enabled by default.
	DisableColors bool

	// Force formatted layout, even for non-TTY output.
	ForceFormatting bool

	// Disable timestamp logging. useful when output is redirected to logging
	// system that already adds timestamps.
	DisableTimestamp bool

	// Disables the truncation of the level text to 4 characters.
	DisableLevelTruncation bool

	// Disable the conversion of the log levels to uppercase
	DisableUppercase bool

	// Enable logging the full timestamp when a TTY is attached instead of just
	// the time passed since beginning of execution.
	FullTimestamp bool

	// Timestamp format to use for display when a full timestamp is printed.
	TimestampFormat string

	// The fields are sorted by default for a consistent output. For applications
	// that log extremely frequently and don't use the JSON formatter this may not
	// be desired.
	DisableSorting bool

	// Wrap empty fields in quotes if true.
	QuoteEmptyFields bool

	// Can be set to the override the default quoting character "
	// with something else. For example: ', or `.
	QuoteCharacter string

	// Pad msg field with spaces on the right for display.
	// The value for this parameter will be the size of padding.
	// Its default value is zero, which means no padding will be applied for msg.
	SpacePadding int

	// Outputs raw message without timestamp or log level.
	DisableDecorations bool

	sync.Once
	// contains filtered or unexported fields
}

TextFormatter is a custom logrus Formatter.

func (*TextFormatter) Format

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

Format changes the appearance of output logs

func (*TextFormatter) SetColorScheme

func (f *TextFormatter) SetColorScheme(colorScheme *ColorScheme)

SetColorScheme changes the color schema of log levels

Jump to

Keyboard shortcuts

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