Categorygithub.com/jhunt/go-log
modulepackage
0.0.0-20171024033145-ddc1e3b8ed30
Repository: https://github.com/jhunt/go-log.git
Documentation: pkg.go.dev

# README

log - Flexible Logging for Go

Travis CI

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

  1. Fork the repo
  2. Write your code in a feature branch
  3. Create a new Pull Request

# Functions

Logs a formatted Alert message.
Logs a formatted Crit message.
Logs a formatted Debug message.
Logs a formatted Emerg message.
Logs a formatted Error message.
Logs a formatted Info message.
Returns true if the looger will log ALERT messages.
Returns true if the looger will log CRIT messages.
Returns true if the looger will log DEBUG messages.
Returns true if the looger will log EMERG messages.
Returns true if the looger will log ERR messages.
Returns true if the looger will log INFO messages.
Returns true if the looger will log NOTICE messages.
Returns true if the looger will log TRACE messages.
Returns true if the looger will log WARNING messages.
Retreives the currently configured log level.
Logs a formatted Notice message.
No description provided by the author
Logs a formatted Trace message.
Logs a formatted Warning message.

# Structs

No description provided by the author