repositorypackage
0.0.0-20171024033145-ddc1e3b8ed30
Repository: https://github.com/jhunt/go-log.git
Documentation: pkg.go.dev
# README
log - Flexible Logging for Go
Setup logging with SetupLogging()
:
- Type: logging mode to use - file, syslog, console
- Level: debug, info, error, etc. (See all levels below.)
- Facility: syslog facility to log to - daemon, misc, etc.
- File: path to log to file if in file mode.
e.g.:
log.SetupLogging(log.LogConfig{
Type: "console",
Level: "warning"
})
If logging is not setup, then the messages will simply go to
stdout
. If logging cannot be setup for file
or syslog
, then
the default stdout
will be used. An error message will print to
stderr
to notify you if this occurs.
The following log levels are defined, in decreasing verbosity / increasing criticality:
- Debug
- Info
- Notice
- Warn
- Error
- Crit
- Alert
- Emerg
Usage
Usage is the same as Sprintf
/Printf
statements - simply append
an f
to the desired level. e.g.:
dbug_mesg := "This isn't a bug."
log.Debugf("I really need to know this in debug mode: %s", msg)
Contributing
- Fork the repo
- Write your code in a feature branch
- Create a new Pull Request