Documentation ¶
Overview ¶
A simple logging layer on top of seelog
Implements multiple log channels to a single rotated log file. Log levels are considered a simple hierarchy with each channel having a single limit, below which logs to that channel are skipped.
Index ¶
- Constants
- func Critical(message string)
- func Criticalf(format string, arguments ...interface{})
- func Finalise()
- func Flush()
- func Initialise(configuration Configuration) error
- func ListLevels() ([]byte, error)
- func Panic(message string)
- func PanicIfError(message string, err error)
- func Panicf(format string, arguments ...interface{})
- func UpdateTagLogLevel(tag, newLevel string) error
- type Configuration
- type L
- func (l *L) Critical(message string)
- func (l *L) Criticalc(closure func() string)
- func (l *L) Criticalf(format string, arguments ...interface{})
- func (l *L) Debug(message string)
- func (l *L) Debugc(closure func() string)
- func (l *L) Debugf(format string, arguments ...interface{})
- func (l *L) Error(message string)
- func (l *L) Errorc(closure func() string)
- func (l *L) Errorf(format string, arguments ...interface{})
- func (l *L) Flush()
- func (l *L) Info(message string)
- func (l *L) Infoc(closure func() string)
- func (l *L) Infof(format string, arguments ...interface{})
- func (l *L) Trace(message string)
- func (l *L) Tracec(closure func() string)
- func (l *L) Tracef(format string, arguments ...interface{})
- func (l *L) Warn(message string)
- func (l *L) Warnc(closure func() string)
- func (l *L) Warnf(format string, arguments ...interface{})
- type Level
- type LogLevels
Constants ¶
const ( // the tagname reserved to set the default level for unknown tags DefaultTag = "DEFAULT" // the initial level for unknown tags DefaultLevel = "error" )
some restrictions on sizes
const ( Major = "0" Minor = "3" Patch = "7" Version = Major + "." + Minor + "." + Patch )
Variables ¶
This section is empty.
Functions ¶
func Criticalf ¶
func Criticalf(format string, arguments ...interface{})
global logging formatted message
func ListLevels ¶ added in v0.3.5
ListLevels - return log level info in json format it's not lock protected, because it should be low frequency to list log levels
func Panicf ¶
func Panicf(format string, arguments ...interface{})
global logging formatted message + panic
func UpdateTagLogLevel ¶ added in v0.3.5
UpdateTagLogLevel - update log level for specific tag
Types ¶
type Configuration ¶
type Configuration struct { Directory string `libucl:"directory" hcl:"directory" json:"directory"` File string `libucl:"file" hcl:"file" json:"file"` Size int `libucl:"size" hcl:"size" json:"size"` Count int `libucl:"count" hcl:"count" json:"count"` Levels map[string]string `libucl:"levels" hcl:"levels" json:"levels"` Console bool `libucl:"console" hcl:"console" json:"console"` }
initial configuration for the logger
example of use (with structure tags for config file parsing)
type AppConfiguration struct { … Logging logger.Configuration `libucl:"logging" hcl:"logging" json:"logging"` … } err := logger.Initialise(conf.Logging) if nil != err { // if failed then display message and exit exitwithstatus.Message("logger error: %s", err) } defer logger.Finalise()
example of ucl/hcl configuration section
logging { directory = "/var/lib/app/log" file = "app.log" size = 1048576 count = 50 #console = true # to duplicate messages to console (default false) levels { DEFAULT = "info" system = "error" main = "warn" } }
type L ¶
The logging channel structure example of use
var log *logger.L log := logger.New("sometag") log.Debugf("value: %d", value)
func (*L) Criticalc ¶
Log from a closure, any function returning a string is suitable and the closure will only be executed if the log level is low enough. This allows complex e.g.
log.Criticalc(func() string { return fmt.Sprintf("the sin(%f) = %f", x, math.sin(x)) })
func (*L) Criticalf ¶
Log a formatted string with arguments lige fmt.Sprintf() e.g.
log.Criticalf("the value = %d", xValue)
func (*L) Debugc ¶
Log from a closure, any function returning a string is suitable and the closure will only be executed if the log level is low enough. This allows complex e.g.
log.Debugc(func() string { return fmt.Sprintf("the sin(%f) = %f", x, math.sin(x)) })
func (*L) Debugf ¶
Log a formatted string with arguments lige fmt.Sprintf() e.g.
log.Debugf("the value = %d", xValue)
func (*L) Errorc ¶
Log from a closure, any function returning a string is suitable and the closure will only be executed if the log level is low enough. This allows complex e.g.
log.Errorc(func() string { return fmt.Sprintf("the sin(%f) = %f", x, math.sin(x)) })
func (*L) Errorf ¶
Log a formatted string with arguments lige fmt.Sprintf() e.g.
log.Errorf("the value = %d", xValue)
func (*L) Infoc ¶
Log from a closure, any function returning a string is suitable and the closure will only be executed if the log level is low enough. This allows complex e.g.
log.Infoc(func() string { return fmt.Sprintf("the sin(%f) = %f", x, math.sin(x)) })
func (*L) Infof ¶
Log a formatted string with arguments lige fmt.Sprintf() e.g.
log.Infof("the value = %d", xValue)
func (*L) Tracec ¶
Log from a closure, any function returning a string is suitable and the closure will only be executed if the log level is low enough. This allows complex e.g.
log.Tracec(func() string { return fmt.Sprintf("the sin(%f) = %f", x, math.sin(x)) })
func (*L) Tracef ¶
Log a formatted string with arguments lige fmt.Sprintf() e.g.
log.Tracef("the value = %d", xValue)