Documentation ¶
Overview ¶
minilog extends Go's logging functionality to allow for multiple loggers, each one with their own logging level. To use minilog, call AddLogger() to set up each desired logger, then use the package-level logging functions defined to send messages to all defined loggers.
Index ¶
- Constants
- Variables
- func AddFilter(name string, filter string) error
- func AddLogger(name string, output io.Writer, level Level, color bool)
- func AddSyslog(network, raddr, tag string, level Level) error
- func Debug(format string, arg ...interface{})
- func Debugln(arg ...interface{})
- func DelFilter(name string, filter string) error
- func DelLogger(name string)
- func Error(format string, arg ...interface{})
- func Errorln(arg ...interface{})
- func Fatal(format string, arg ...interface{})
- func Fatalln(arg ...interface{})
- func Filters(name string) ([]string, error)
- func Info(format string, arg ...interface{})
- func Infoln(arg ...interface{})
- func Init()
- func LogAll(i io.Reader, level Level, name string)
- func Loggers() []string
- func SetLevel(name string, level Level) error
- func SetLevelAll(level Level)
- func Warn(format string, arg ...interface{})
- func Warnln(arg ...interface{})
- func WillLog(level Level) bool
- type Level
Constants ¶
const ( Reset = "\x1b[0m" Bright = "\x1b[1m" Dim = "\x1b[2m" Underscore = "\x1b[4m" Blink = "\x1b[5m" Reverse = "\x1b[7m" Hidden = "\x1b[8m" FgBlack = "\x1b[30m" FgRed = "\x1b[31m" FgGreen = "\x1b[32m" FgYellow = "\x1b[33m" FgBlue = "\x1b[34m" FgMagenta = "\x1b[35m" FgCyan = "\x1b[36m" FgWhite = "\x1b[37m" BgBlack = "\x1b[40m" BgRed = "\x1b[41m" BgGreen = "\x1b[42m" BgYellow = "\x1b[43m" BgBlue = "\x1b[44m" BgMagenta = "\x1b[45m" BgCyan = "\x1b[46m" BgWhite = "\x1b[47m" )
Some color constants for output
const DefaultLevel = ERROR
Variables ¶
var ( LevelFlag = DefaultLevel VerboseFlag bool FileFlag string )
Functions ¶
func AddLogger ¶
Adds a logger set to log only events at level specified or higher. output: io.Writer instance to which to log (can be os.Stderr or os.Stdout) level: one of the minilogging levels defined as a constant
func AddSyslog ¶
Helper function to add syslog output by connecting to address raddr on the specified network. Events are logged with a specified tag. Calling more than once overwrites existing syslog writers. If network == "local", log to the local syslog daemon.
func Init ¶
func Init()
Setup log according to flags and OS. Replaces the logSetup() that each package used to have.
func LogAll ¶
Log all input from an io.Reader, splitting on lines, until EOF. LogAll starts a goroutine and returns immediately.
func SetLevelAll ¶
func SetLevelAll(level Level)
SetLevelAll changes the log level for all loggers to the provided level
Types ¶
type Level ¶
type Level int
const ( DEBUG Level INFO WARN ERROR FATAL )
Log levels supported: DEBUG -> INFO -> WARN -> ERROR -> FATAL
func ParseLevel ¶
ParseLevel returns the log level from a string.