Documentation ¶
Index ¶
- Constants
- Variables
- func BUG(f string, args ...interface{})
- func CRIT(f string, args ...interface{})
- func CRITon() bool
- func DBG(f string, args ...interface{})
- func DBGon() bool
- func DefaultLogInit(lev LogLevel, opt LogOptions, logger LogOutput)
- func DefaultLogSetLevel(lev LogLevel)
- func DefaultLogSetOptions(opt LogOptions)
- func DefaultLogSetOutput(out LogOutput)
- func ERR(f string, args ...interface{})
- func ERRon() bool
- func INFO(f string, args ...interface{})
- func INFOon() bool
- func Init(l *Log, lev LogLevel, opt LogOptions, logger LogOutput)
- func L(l LogLevel) bool
- func LevelName(l LogLevel) string
- func LogOptString(o LogOptions) (string, bool)
- func NOTICE(f string, args ...interface{})
- func NOTICEon() bool
- func PANIC(f string, args ...interface{})
- func SetLevel(l *Log, lev LogLevel)
- func SetOptions(l *Log, opt LogOptions)
- func SetOutput(l *Log, out LogOutput)
- func WARN(f string, args ...interface{})
- func WARNon() bool
- type Log
- func (l Log) BUG(f string, args ...interface{})
- func (l Log) BUGon() bool
- func (l Log) CRITon() bool
- func (l Log) DBG(fmt string, args ...interface{})
- func (l Log) DBGon() bool
- func (l Log) ERR(f string, args ...interface{})
- func (l Log) ERRon() bool
- func (l Log) GetLevel() LogLevel
- func (l Log) GetLogger() LogOutput
- func (l Log) GetOpt() LogOptions
- func (l Log) INFO(f string, args ...interface{})
- func (l Log) INFOon() bool
- func (l Log) L(lev LogLevel) bool
- func (l Log) LLog(lev LogLevel, callersSkip int, prefix string, f string, args ...interface{})
- func (l Log) Log(lev LogLevel, f string, args ...interface{})
- func (l Log) LogMux(w io.Writer, wcond bool, lev LogLevel, f string, args ...interface{})
- func (l Log) NOTICEon() bool
- func (l Log) PANIC(f string, args ...interface{})
- func (l Log) WARN(f string, args ...interface{})
- func (l Log) WARNon() bool
- type LogLevel
- type LogOptions
- type LogOutput
Constants ¶
const ( BufPoolSz = 128 // maximum buffer in pool, must be 2^k BufSz = 1024 // typical buf sz MaxBufSz = 65534 // max allowed (if more reset) )
keep a pool of bytes.Buffer(s) for fast re-use
const Version = "0.1.1"
Variables ¶
var BuildTags []string
Functions ¶
func DefaultLogInit ¶
func DefaultLogInit(lev LogLevel, opt LogOptions, logger LogOutput)
func DefaultLogSetLevel ¶
func DefaultLogSetLevel(lev LogLevel)
func DefaultLogSetOptions ¶
func DefaultLogSetOptions(opt LogOptions)
func DefaultLogSetOutput ¶
func DefaultLogSetOutput(out LogOutput)
func Init ¶
func Init(l *Log, lev LogLevel, opt LogOptions, logger LogOutput)
Init initialises a log with a given maximum log level, options and output type.
func LevelName ¶ added in v0.0.2
LevelName returns the log level name as string. On error it returns the empty string.
func LogOptString ¶ added in v0.0.2
func LogOptString(o LogOptions) (string, bool)
LogOptString returns the log options as string (seprated by "|"). It returns the string representation of the options and a boolean specifying if all the options are known (true) or if an error was encountered (false)
Types ¶
type Log ¶
type Log uint64
Log is a simple logger, keeping all its configuration inside an uint64. Format: LogOutput | LogOptions | LogLevel (3 bytes used, 5 free)
func New ¶
func New(lev LogLevel, opt LogOptions, logger LogOutput) Log
New returns a new log, intialised with the give options
func (Log) DBG ¶
DBG logs a message at the LDBG level with a DBG prefix (shorthand for Log(LDBG, "DBG: ", ...))
func (Log) ERR ¶
ERR logs a message at the LERR level with a ERROR prefix (shorthand for Log(LERR, "ERROR: ", ...))
func (Log) INFO ¶
INFO logs a message at the LINFO level with an INFO prefix (shorthand for Log(LINFO, "INFO: ", ...))
func (Log) L ¶
L returns true if the specified level is enabled for logging. Can be used to quickly check if logging is enabled, before calling a logging function (thus avoiding unneeded parameter evaluation).
func (Log) LLog ¶
LLog logs a message with a given prefix at a given level. It is supposed to be used mostly internally. The callersSkip parameter is used to find the caller for which to print the file/line information or where the backtrace should start.
func (Log) LogMux ¶
LogMux() will write the message both to the passed io.Writer and to the log. The message is written to the io.Writer independent of the log level and only if wcond is true. The message in the log will have added prefixes depending on the log options.
type LogOptions ¶
type LogOptions uint8
LogOptions is the type used for the log options.
const ( LOptNone LogOptions = 0 LlocInfoS LogOptions = 1 << 0 // short filenames LlocInfoL LogOptions = 1 << 1 // long version (complete filenames) LtimeStamp LogOptions = 1 << 2 LbackTraceS LogOptions = 1 << 3 // short LbackTraceL LogOptions = 1 << 4 // long )
log options