logging

package
v0.0.0-...-6244057 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2018 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TIME_FORMAT  = "2006-01-02T15:04:05Z07:00"
	DATE_FORMAT  = "2006-01-02"
	CLOCK_FORMAT = "15:04:05"

	// cannot continue, aborting immidiatly
	EMERGENCY        = 0x01
	EMERGENCY_SYSLOG = 1
	// require immidiate attention
	CRITICAL        = 0x02
	CRITICAL_SYSLOG = 2
	// not used
	ALERT        = CRITICAL
	ALERT_SYSLOG = 3
	// an error that was recovered
	ERROR        = 0x04
	ERROR_SYSLOG = 4
	// warning. space nearly full etc.
	WARNING        = 0x08
	WARNING_SYSLOG = 5
	// notice. behaviour will change, found this driver etc.
	NOTICE        = 0x16
	NOTICE_SYSLOG = 6
	// info. version info, something succeded etc.
	INFO        = 0x32
	INFO_SYSLOG = 7
	// debug. favourite time of programming
	DEBUG        = 0x64
	DEBUG_SYSLOG = 8

	// EMERGENCY & CRITICAL
	FATAL = 0x03
	// FATAL & ERROR
	ERRORS = 0x07
	// ERRORS & WARNING
	WARNINGS = 0x15
	// WARNINGS & NOTICE
	VERBOSE = 0x31
	// VERBOSE & INFO
	ATTENTION = 0x63
	// VERBOSE & DEBUG
	DEBUGGING = 0x7f
	// max
	EVERYTHING = 0xff
)

Variables

This section is empty.

Functions

func Close

func Close() (e error)

the end is at hand

func Critical

func Critical(message ...interface{})

require immidiate attention

func CriticalFormat

func CriticalFormat(format string, message ...interface{})

require immidiate attention

func Debug

func Debug(message ...interface{})

debug. favourite time of programming

func DebugFormat

func DebugFormat(format string, message ...interface{})

debug, favourite time of programming

func Emergency

func Emergency(message ...interface{})

cannot continue, aborting immidiatly

func EmergencyFormat

func EmergencyFormat(format string, message ...interface{})

cannot continue, aborting immidiatly

func Error

func Error(message ...interface{})

an error that was recovered

func ErrorFormat

func ErrorFormat(format string, message ...interface{})

an error that was recovered

func ForceStart

func ForceStart(config LogConfigInterface)

either start logging or panic

func Info

func Info(message ...interface{})

info: version info, something succeded etc.

func InfoFormat

func InfoFormat(format string, message ...interface{})

info: version info, something succeded etc.

func LevelToInt

func LevelToInt(level string) uint8

func LevelToString

func LevelToString(level uint8) string

func LimitString

func LimitString(input string) string

func Log

func Log(level uint8, message ...interface{})

DEPRECATED log a message; call Start() first.

func LogFormat

func LogFormat(level uint8, format string, message ...interface{})

DEPRECATED; rename to logFormat() log a formatted message

func NewFileLogger

func NewFileLogger(config LogConfigInterface) (file *fileLogger)

func NewNullLogger

func NewNullLogger(config LogConfigInterface) (null *nullLogger)

func NewStderrLogger

func NewStderrLogger(config LogConfigInterface) (stderr *stderrLogger)

func NewSyslogLogger

func NewSyslogLogger(config LogConfigInterface) (sys *syslogLogger)

func Notice

func Notice(message ...interface{})

notice: behaviour will change, found this driver etc.

func NoticeFormat

func NoticeFormat(format string, message ...interface{})

notice: behaviour will change, found this driver etc.

func Panic

func Panic(message ...interface{})

log with EMERGENCY and then panic with the message

func PanicFormat

func PanicFormat(format string, message ...interface{})

log with EMERGENCY and then panic with the message with format

func SanitizeString

func SanitizeString(input string) string

generic string sanitizing specific sanitizing must still be done in specific loggers

func Start

func Start(config LogConfigInterface) (e error)

start logging; flushes early log from StartEarly()

func StartEarly

func StartEarly()

log to memory first, as this requires no real configuration. Start() will flush this logger to the actual logger

func Warning

func Warning(message ...interface{})

warning: space nearly full etc.

func WarningFormat

func WarningFormat(format string, message ...interface{})

warning: space nearly full etc.

Types

type DefaultConfig

type DefaultConfig struct {
	// program name
	Name string
	// type of logger TODO
	LogType Type
	// log level
	Level uint8
	// error handler (name string, e error)
	EHandler func(string, error)
	// contains filtered or unexported fields
}

func NewDefaultConfig

func NewDefaultConfig() (config *DefaultConfig)

func (*DefaultConfig) GetEHandler

func (config *DefaultConfig) GetEHandler() func(name string, e error)

func (*DefaultConfig) GetLevel

func (config *DefaultConfig) GetLevel() uint8

func (*DefaultConfig) GetName

func (config *DefaultConfig) GetName() string

func (*DefaultConfig) GetType

func (config *DefaultConfig) GetType() Type

func (*DefaultConfig) HandleE

func (config *DefaultConfig) HandleE(name string, e error)

func (*DefaultConfig) IsPlain

func (config *DefaultConfig) IsPlain() bool

func (*DefaultConfig) SetEHandler

func (config *DefaultConfig) SetEHandler(to func(name string, e error))

func (*DefaultConfig) SetLevel

func (config *DefaultConfig) SetLevel(to uint8)

func (*DefaultConfig) TogglePlain

func (config *DefaultConfig) TogglePlain()

type DefaultFileConfig

type DefaultFileConfig struct {
	DefaultConfig
	Path string
}

func NewDefaultFileConfig

func NewDefaultFileConfig() (config *DefaultFileConfig)

func (*DefaultFileConfig) GetPath

func (config *DefaultFileConfig) GetPath() string

type LogConfigInterface

type LogConfigInterface interface {
	// name of you program
	GetName() string
	// main log type (null, stderr, file, syslog ...)
	GetType() Type
	// additional loggers
	//GetSecondaryTypes() []string
	// verbosity, see tools.go:LevelToString
	GetLevel() uint8
	SetLevel(to uint8)

	// error handling
	GetEHandler() func(string, error)
	SetEHandler(to func(string, error))
	HandleE(string, error)

	// plain mode (no colors, no highlights etc)
	IsPlain() bool
	// set to plain mode (default: false)
	TogglePlain()
}

configuration

type Type

type Type uint8
const (
	NULL   Type = 0
	BUFFER Type = 1
	FILE   Type = 2
	SYS    Type = 3
	STDERR Type = 4
)

Jump to

Keyboard shortcuts

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