logger

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(msg string)

func Debugf

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

func Error

func Error(msg string)

func Errorf

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

func Fatal

func Fatal(msg string)

func Fatalf

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

func GetDelegate

func GetDelegate() interface{}

func GetDesugaredZapLoggerDelegate

func GetDesugaredZapLoggerDelegate(instance Logger) (*zap.Logger, error)

func GetZapLoggerDelegate

func GetZapLoggerDelegate(instance Logger) (*zap.SugaredLogger, error)

func Info

func Info(msg string)

func Infof

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

func Panic

func Panic(msg string)

func Panicf

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

func Sync

func Sync() error

func Warn

func Warn(msg string)

func Warnf

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

Types

type Configuration

type Configuration struct {
	EnableConsole     bool   `` /* 143-byte string literal not displayed */
	ConsoleJSONFormat bool   `` /* 166-byte string literal not displayed */
	ConsoleLevel      string `` /* 184-byte string literal not displayed */
	EnableFile        bool
	FileJSONFormat    bool
	FileLevel         string
	FileLocation      string
}

Configuration 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

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 {
	Debug(msg string)
	Debugf(format string, args ...interface{})

	Info(msg string)
	Infof(format string, args ...interface{})

	Warn(msg string)
	Warnf(format string, args ...interface{})

	Error(msg string)
	Errorf(format string, args ...interface{})

	Fatal(msg string)
	Fatalf(format string, args ...interface{})

	Panic(msg string)
	Panicf(format string, args ...interface{})

	WithFields(keyValues Fields) Logger

	GetDelegate() interface{}

	Sync() error
}

Logger is our contract for the logger

func DefaultLogger

func DefaultLogger() Logger

DefaultLogger creates default logger, which uses zap sugarlogger and outputs to console

func InitLogger

func InitLogger(config Configuration, backend LoggerBackend) (Logger, error)

InitLogger returns an instance of logger

func NewLogger

func NewLogger(config Configuration, backend LoggerBackend) (Logger, error)

func WithFields

func WithFields(keyValues Fields) Logger

type LoggerBackend

type LoggerBackend int

LoggerBackend reprents the int enum for backend of logger (exists for legacy compat reason) nolint:revive

const (
	// LoggerBackendZap logging using Uber's zap backend
	LoggerBackendZap LoggerBackend = iota
	// LoggerBackendLogrus logging using logrus backend
	LoggerBackendLogrus
)

Jump to

Keyboard shortcuts

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