Documentation ¶
Overview ¶
Package loggie provides simple unstructured leveled logging.
Index ¶
- Constants
- Variables
- func Debug(v ...interface{})
- func Debugf(format string, v ...interface{})
- func Error(v ...interface{})
- func Errorf(format string, v ...interface{})
- func Fatal(v ...interface{})
- func Fatalf(format string, v ...interface{})
- func Info(v ...interface{})
- func Infof(format string, v ...interface{})
- func Level() int
- func Panic(v ...interface{})
- func Panicf(format string, v ...interface{})
- func Print(lvl int, v ...interface{})
- func Printf(lvl int, format string, v ...interface{})
- func SetLevel(lvl int)
- func Warning(v ...interface{})
- func Warningf(format string, v ...interface{})
- type Formatter
- type Logger
Constants ¶
const ( Fdate = 1 << iota Ftime Fmilliseconds Futc Flevel Fname Fcolor Fdefault = Fdate | Ftime | Fmilliseconds | Flevel | Fname )
These flags define which info will be included to each entry generated by the logger. By default, all logging entries are prefixed by date, time, level and logger name.
const ( Ldebug = iota Linfo Lwarning Lerror Lfatal Lpanic Lnone )
Known logging levels. Setting logging level to Lnone silences all logging output (including Fatal and Panic logging).
Variables ¶
var ( Cdate = "\033[0;37m" Ctime = "\033[0;37m" Cname = "\033[0;35m" )
Colors for date, time and logger name fields.
var Mlevel = map[int][2]string{
Ldebug: {"DBG", "\033[97;42m"},
Linfo: {"INF", "\033[97;44m"},
Lwarning: {"WRN", "\033[97;43m"},
Lerror: {"ERR", "\033[97;41m"},
Lfatal: {"FTL", "\033[97;5;41m"},
Lpanic: {"PAN", "\033[97;5;41m"},
}
Mlevel defines logging level field colorization.
Functions ¶
Types ¶
type Formatter ¶
type Formatter interface { Format(w io.Writer, lvl int, name string, msg string) error Flags() int SetFlags(flags int) }
Formatter is the interface implemented by output formatters.
var DefaultFormatter Formatter
Default formatter is default output formatter. It produces colorized output if output destination is a tty and plain text otherwise. Colorization additionally can be controller by CLICOLOR and CLICOLOR_FORCE environment variables: CLICOLOR=0 disables colorization and CLICOLOR_FORCE=1 forces it even when output is not a tty.
func NewTextFormatter ¶
NextTextFormatter returns new default unstructured text formatter.
type Logger ¶
type Logger interface { Print(lvl int, v ...interface{}) Printf(lvl int, format string, v ...interface{}) Debug(v ...interface{}) Debugf(format string, v ...interface{}) Info(v ...interface{}) Infof(format string, v ...interface{}) Warning(v ...interface{}) Warningf(format string, v ...interface{}) Error(v ...interface{}) Errorf(format string, v ...interface{}) Panic(v ...interface{}) Panicf(format string, v ...interface{}) Fatal(v ...interface{}) Fatalf(format string, v ...interface{}) Level() int SetLevel(lvl int) }
Logger is the logging interface.
var Default Logger