logger

package
v0.0.0-...-d5fa0d2 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Mode    LogMode
	Console ConsoleConfig
}

Config represent high-level logger configuration.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig provides ready to use configuration for development mode. It is configured to support only console output with Debug logging level.

type ConsoleConfig

type ConsoleConfig struct {
	Enabled bool
	Level   LogLevel
	Format  string
}

ConsoleConfig groups configuration bits

type EchoMiddlewareLogger

type EchoMiddlewareLogger struct {
	DebugOnly bool
	// contains filtered or unexported fields
}

EchoMiddlewareLogger is Echo Middleware compatible adapter.

func NewEchoMiddlewareLogger

func NewEchoMiddlewareLogger(lgr Logger) *EchoMiddlewareLogger

NewEchoMiddlewareLogger serve as adaptation layer to convert application logger to be compatible with echo framework middleware logging logic.

func (*EchoMiddlewareLogger) Write

func (h *EchoMiddlewareLogger) Write(data []byte) (int, error)

type LogLevel

type LogLevel string

LogLevel represent different depths for logged informations about the system.

const (
	// Debug level logging, should be disabled in production mode.
	Debug LogLevel = "debug"
	// Info level logging, default logging setting
	Info LogLevel = "info"
	// Warn level logging used to mark possible issues in code execution.
	// For convenience "warn" spelling is also accepted.
	Warn LogLevel = "warning"
	// Error level logging logs errors
	Error LogLevel = "error"
	// Fatal level logging, log is recorded and application terminates after.
	Fatal LogLevel = "fatal"
)

type LogMode

type LogMode string

LogMode defines different logging strategies.

const (
	DevelopMode    LogMode = "develop"
	ProductionMode LogMode = "production"
)

type Logger

type Logger interface {
	Debug(args ...interface{})
	Debugf(format string, args ...interface{})
	Info(args ...interface{})
	Infof(format string, args ...interface{})
	Warn(args ...interface{})
	Warnf(format string, args ...interface{})
	Error(args ...interface{})
	Errorf(format string, args ...interface{})
	Fatal(args ...interface{})
	Fatalf(format string, args ...interface{})
	WithPrefix(pfx string) Logger
}

logger interface describes logging abstraction layer.

func New

func New(cfg Config) Logger

New returns an instance of structured logger.

type NOP

type NOP struct{}

NOP provide no-ops implementation for Logger interface.

func (NOP) Debug

func (nl NOP) Debug(args ...interface{})

func (NOP) Debugf

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

func (NOP) Error

func (nl NOP) Error(args ...interface{})

func (NOP) Errorf

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

func (NOP) Fatal

func (nl NOP) Fatal(args ...interface{})

func (NOP) Fatalf

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

func (NOP) Info

func (nl NOP) Info(args ...interface{})

func (NOP) Infof

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

func (NOP) Warn

func (nl NOP) Warn(args ...interface{})

func (NOP) Warnf

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

func (NOP) WithPrefix

func (nl NOP) WithPrefix(name string) Logger

Jump to

Keyboard shortcuts

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