Categorygithub.com/opencoff/go-logger
modulepackage
0.7.3
Repository: https://github.com/opencoff/go-logger.git
Documentation: pkg.go.dev

# README

go-logger - Level based logger with sub-logger support

What is it?

Borrowed from golang stdlib, this enables logging at increasing levels of verbosity. The verbosity increases as we go down the list below:

  • Emergency (LOG_EMERG) - will halt the program after printing a backtrace of the calling goroutine.
  • Critical (LOG_CRIT)
  • Error (LOG_ERR) - all levels at and above will print a stack-trace of the calling goroutine.
  • Warning (LOG_WARNING)
  • Informational (LOG_INFO) - this is the level at which I log most informational messages useful for troubleshooting production issues.
  • Debug (LOG_DEBUG) - this is the most verbose level

List of enhancements from the stdlib

  • All I/O is done asychronously; the caller doesn't incur I/O cost

  • A single program can have multiple loggers - each with a different priority.

  • An instance of a logger is configured with a given log level; and it only prints log messages "above" the configured level. e.g., if a logger is configured with level of INFO, then it will print all log messages with INFO and higher priority; in particular, it won't print DEBUG messages.

  • A single program can have multiple loggers; each with a different priority.

  • The logger method Backtrace() will print a stack backtrace to the configured output stream. Log levels are NOT considered when backtraces are printed.

  • The Panic() and Fatal() logger methods implicitly print the stack backtrace (upto 5 levels).

  • DEBUG, ERR, CRIT log outputs (via Debug(), Err() and Crit() methods) also print the source file location from whence they were invoked.

  • New package functions to create a syslog(1) or a file logger instance.

  • Callers can create a new logger instance if they have an io.writer instance of their own - in case the existing output streams (File and Syslog) are insufficient.

  • Any logger instance can create child-loggers with a different priority and prefix (but same destination); this is useful in large programs with different modules.

  • Compressed log rotation based on daily time-of-day (configurable ToD) -- only available for file-backed destinations.

  • Wrapper available to make this logger appear like a stdlib logger; this wrapper prints everything sent to it (it's an io.Writer)

# Functions

Creates a new Logger instance at the given priority.
Creates a new file-backed logger instance at the given priority.
Creates a new logging instance.
NewNoneLogger creates a logger where all log entries are thrown away.
Creates a new syslog-backed logger instance at the given priority.
Convert a string to equivalent Priority.

# Constants

the date: 2009/01/23.
put file name and line number in the log.
full file path and line number: /a/b/c/d.go:23.
microsecond resolution: 01:23:23.123123.
Log Priorities.
Log Priorities.
Log Priorities.
Log Priorities.
Log Priorities.
Log Priorities.
Log Priorities.
print relative time from start of program.
initial values for the standard logger.
the time: 01:23:23.

# Interfaces

A Logger represents an active logging object that generates lines of output to an io.Writer.
A RotatableLogger represents an active _file backed_ Logger instance.

# Type aliases

Log priority.