lumber

package
v0.0.0-...-f347ef5 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Debug has verbose message
	Debug = "debug"
	// Info is default log level
	Info = "info"
	// Warn is for logging messages about possible issues
	Warn = "warn"
	// Error is for logging errors
	Error = "error"
	// Fatal is for logging fatal messages. The system shutsdown after logging the message.
	Fatal = "fatal"
)
View Source
const (
	InstanceZapLogger int = iota
	InstanceLogrusLogger
)

List of supported loggers.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fields

type Fields map[string]interface{}

Fields Type to pass when we want to call WithFields for structured logging

type Logger

type Logger interface {
	// Debugf logs a message at level Debug on the standard logger.
	Debugf(format string, args ...interface{})
	// Infof logs a message at level Info on the standard logger.
	Infof(format string, args ...interface{})
	// Warnf logs a message at level Warn on the standard logger.
	Warnf(format string, args ...interface{})
	// Errorf logs a message at level Error on the standard logger.
	Errorf(format string, args ...interface{})
	// Fatalf logs a message at level Fatal on the standard logger then the process will exit with status set to 1.
	Fatalf(format string, args ...interface{})
	// Panicf logs a message at level Panic on the standard logger.
	Panicf(format string, args ...interface{})
	// WithField creates an entry from the standard logger and adds a field to
	// it. If you want multiple fields, use `WithFields`
	// Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal
	// or Panic on the Entry it returns.
	WithFields(keyValues Fields) Logger
}

Logger is our contract for the logger

func NewLogger

func NewLogger(config LoggingConfig, verbose bool, loggerInstance int) (Logger, error)

NewLogger returns an instance of logger

type LoggingConfig

type LoggingConfig struct {
	EnableConsole     bool
	ConsoleJSONFormat bool
	ConsoleLevel      string
	EnableFile        bool
	FileJSONFormat    bool
	FileLevel         string
	FileLocation      string
}

LoggingConfig stores the config for the logger For some loggers there can only be one level across writers, for such the level of Console is picked by default

Jump to

Keyboard shortcuts

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