logger

package
v0.0.0-...-9a2df54 Latest Latest
Warning

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

Go to latest
Published: May 17, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithBuildInfo

func WithBuildInfo(logger Interface)

WithBuildInfo is an utility func that attaches the cmd build information - * process id of the caller, * golang version, * args other params

Types

type Interface

type Interface interface {
	// With attached attributes to eveery log
	With(args ...any)
	// Resets the logger to how it was instantiated.
	Reset()
	// Debug log a message at DEBUG level
	Debug(message string, args ...any)
	// Error log a message at ERROR level
	Error(message string, args ...any)
	// Fatal log a message at FATAL level
	Fatal(message string, args ...any)
	// Info log a message at INFO level
	Info(message string, args ...any)
	// Warn log a message at WARN level
	Warn(message string, args ...any)
}

Interface is a logger interface that ensures different log library can be used and swap with ease.

type LogDisplayType

type LogDisplayType string
const (
	DisplayTypeJson LogDisplayType = "json"
	DisplayTypeText LogDisplayType = "text"
)

func (LogDisplayType) IsValid

func (l LogDisplayType) IsValid() bool

func (LogDisplayType) String

func (l LogDisplayType) String() string

type LogLevel

type LogLevel string
const (
	LevelError LogLevel = "error"
	LevelWarn  LogLevel = "warn"
	LevelInfo  LogLevel = "info"
	LevelDebug LogLevel = "debug"
)

LogLevels define the various levels of log available

func (LogLevel) IsValid

func (l LogLevel) IsValid() bool

func (LogLevel) String

func (l LogLevel) String() string

type SlogLogger

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

SlogLogger wraps the sirupsen/logrus library in a way that is compatible with our cache interface

func NewSlogLogger

func NewSlogLogger(level LogLevel, logFormatType LogDisplayType, AddSource bool, output io.Writer) *SlogLogger

func (*SlogLogger) Debug

func (l *SlogLogger) Debug(msg string, args ...any)

func (*SlogLogger) Error

func (l *SlogLogger) Error(msg string, args ...any)

func (*SlogLogger) Fatal

func (l *SlogLogger) Fatal(msg string, args ...any)

func (*SlogLogger) Info

func (l *SlogLogger) Info(msg string, args ...any)

func (*SlogLogger) Reset

func (l *SlogLogger) Reset()

func (*SlogLogger) Warn

func (l *SlogLogger) Warn(msg string, args ...any)

func (*SlogLogger) With

func (l *SlogLogger) With(args ...any)

Jump to

Keyboard shortcuts

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