Documentation
¶
Overview ¶
Package log0 is a simple, pluggable logging library.
A more detailed usage guide can be found at https://github.com/danielkov/log0.
Simple example:
var log = log0.Default()
func main() {
defer log.Close()
log.Info("This message will log at INFO level.")
}
Index ¶
- Constants
- Variables
- func DefaultFormatter(l Log) string
- func SimpleFormatter(l Log) string
- type Formatter
- type Log
- type Logger
- func (l *Logger) Close() error
- func (l *Logger) Debug(message string) error
- func (l *Logger) Error(message string) error
- func (l *Logger) Exclude(levels ...level)
- func (l *Logger) Fatal(message string) error
- func (l *Logger) Fine(message string) error
- func (l *Logger) Finest(message string) error
- func (l *Logger) Include(levels ...level)
- func (l *Logger) Info(message string) error
- func (l *Logger) Level(lv level)
- func (l *Logger) Trace(message string) error
- func (l *Logger) Warning(message string) error
Constants ¶
const ( FINEST level = iota FINE DEBUG TRACE INFO WARNING ERROR FATAL OFF )
Pseudo-enum of all logging levels
Variables ¶
var (
DefaultLevels = []level{INFO, WARNING, ERROR, FATAL}
)
Logging levels to use by default
Functions ¶
func DefaultFormatter ¶
DefaultFormatter is a Formatter function that returns the log in the format:
<time(UNIXDate)> [<level>] - <message> :: <filename>:<line> -> <function>
func SimpleFormatter ¶
SimpleFormatter is a Formatter function that returns the log in the format:
<time> [<level>] <function> - <message>
Types ¶
type Formatter ¶
Formatter is a function type that is used on the Logger to create a string representation of the Log object
type Log ¶
Log is a struct that contains meta data about the log that is created by the methods on Logger. Not every Log will be written, only the ones that have a level, which is included in the Loggers levels.
type Logger ¶
Logger is a struct that takes in a *bufio.Writer which it writes to with the corresponding logging methods
func Default ¶
func Default() Logger
Default is a function that returns an instance of Logger with the default config: os.Stdout as output, INFO level, trace generation and DefaultFormatter
func (*Logger) Close ¶
Close is a method that cleans up after the Logger is no longer needed. Calling Close() is important because it flushes the buffered writer
func (*Logger) Debug ¶
Debug is a logger method that logs the message with the Loggers formatting at DEBUG level
func (*Logger) Error ¶
Error is a logger method that logs the message with the Loggers formatting at ERROR level
func (*Logger) Exclude ¶
func (l *Logger) Exclude(levels ...level)
Exclude is a method that takes anu number of levels and removes them from the list of log levels to be displayed
func (*Logger) Fatal ¶
Fatal is a logger method that logs the message with the Loggers formatting at FATAL level
func (*Logger) Fine ¶
Fine is a logger method that logs the message with the Loggers formatting at FINE level
func (*Logger) Finest ¶
Finest is a logger method that logs the message with the Loggers formatting at FNST level
func (*Logger) Include ¶
func (l *Logger) Include(levels ...level)
Include is a method that takes any number of levels and adds them to the list of log levels to be displayed
func (*Logger) Info ¶
Info is a logger method that logs the message with the Loggers formatting at INFO level
func (*Logger) Level ¶
func (l *Logger) Level(lv level)
Level is a method that takes a single level, above which it will include all levels in the logs with the supplied level included
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
default
command
|
|
|
file
command
|
|
|
formatter
command
|
|
|
simple_format
command
|
