logger

package
v0.0.0-...-b1b50a1 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package logger gathers all possible type of logging, from console logging to remote log management

Index

Constants

This section is empty.

Variables

View Source
var LogLevelDebug = LogLevel{
	// contains filtered or unexported fields
}

LogLevelDebug for development

View Source
var LogLevelError = LogLevel{
	// contains filtered or unexported fields
}

LogLevelError now that's a problem

View Source
var LogLevelFatal = LogLevel{
	// contains filtered or unexported fields
}

LogLevelFatal is "Holy cow, we're fucked"

View Source
var LogLevelInfo = LogLevel{
	// contains filtered or unexported fields
}

LogLevelInfo for standard logging

View Source
var LogLevelVerbose = LogLevel{
	// contains filtered or unexported fields
}

LogLevelVerbose to say everything

View Source
var LogLevelWarn = LogLevel{
	// contains filtered or unexported fields
}

LogLevelWarn is...starting to get problems

Functions

This section is empty.

Types

type ConsoleLogger

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

ConsoleLogger is the standard STDOUT logger

func NewConsoleLogger

func NewConsoleLogger(level LogLevel) *ConsoleLogger

NewConsoleLogger is the ConsoleLogger constructor

func (*ConsoleLogger) Debug

func (cl *ConsoleLogger) Debug(format string, args ...interface{})

Debug prints logs in the console

func (*ConsoleLogger) Error

func (cl *ConsoleLogger) Error(format string, args ...interface{})

Error prints logs in the console

func (*ConsoleLogger) Fatal

func (cl *ConsoleLogger) Fatal(exitCode int, format string, args ...interface{})

Fatal is MAYDAY MAYDAY

Fatal mimics the behaviour of `log.Fatalf` with a custom exit code

func (*ConsoleLogger) Info

func (cl *ConsoleLogger) Info(format string, args ...interface{})

Info prints logs in the console

func (*ConsoleLogger) LogLevel

func (cl *ConsoleLogger) LogLevel() LogLevel

LogLevel returns logger current logging level

func (*ConsoleLogger) Verbose

func (cl *ConsoleLogger) Verbose(format string, args ...interface{})

Verbose prints logs in the console

func (*ConsoleLogger) Warn

func (cl *ConsoleLogger) Warn(format string, args ...interface{})

Warn prints logs in the console

type LogLevel

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

LogLevel defines the minimum logging for a specific logger

func (*LogLevel) WillLog

func (lvl *LogLevel) WillLog(targetLevel LogLevel) bool

WillLog checks the current logger has a sufficient logging level to continue

type Logger

type Logger interface {
	// Verbose is mainly used during develop, well, flooding !
	Verbose(format string, args ...interface{})

	// Debug is expected to be relevant only for development environment
	Debug(format string, args ...interface{})

	// Standard logging level
	Info(format string, args ...interface{})

	// Something went wrong but the involved process could finish
	Warn(format string, args ...interface{})

	// Something went wrong but the involved process could NOT finish
	Error(format string, args ...interface{})
	// The app crashed
	Fatal(exitCode int, format string, args ...interface{})

	// Logger logging level is a read-only property
	LogLevel() LogLevel
}

Logger defines logging behaviour.

A logger is expected to:

  • have multiple levels of logging depending on the severity of the logged message
  • has a stand-alone configuration, not bound to some API definition or other loggers
  • Automatically handle new line characters whenever required

type SilenceLogger

type SilenceLogger struct {
}

SilenceLogger is the standard STDOUT logger

func NewSilenceLogger

func NewSilenceLogger() *SilenceLogger

NewSilenceLogger is the SilenceLogger constructor

func (*SilenceLogger) Debug

func (cl *SilenceLogger) Debug(format string, args ...interface{})

Debug prints logs in the console

func (*SilenceLogger) Error

func (cl *SilenceLogger) Error(format string, args ...interface{})

Error prints logs in the console

func (*SilenceLogger) Fatal

func (cl *SilenceLogger) Fatal(exitCode int, format string, args ...interface{})

Fatal is MAYDAY MAYDAY

Fatal mimics the behaviour of `log.Fatalf` with a custom exit code

func (*SilenceLogger) Info

func (cl *SilenceLogger) Info(format string, args ...interface{})

Info prints logs in the console

func (*SilenceLogger) LogLevel

func (cl *SilenceLogger) LogLevel() LogLevel

LogLevel returns logger current logging level

func (*SilenceLogger) Verbose

func (cl *SilenceLogger) Verbose(format string, args ...interface{})

Verbose prints logs in the console

func (*SilenceLogger) Warn

func (cl *SilenceLogger) Warn(format string, args ...interface{})

Warn prints logs in the console

Jump to

Keyboard shortcuts

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