# README
Log
Log is a flexible logger for Golang applications. Inspired by xfxdev/xlog.
NOTICE Neither
Fatal(f)
norPanic(f)
functions exit the running code.
Installation
go get github.com/nszilard/log
Features
• Level logging
Support 7 different log levels, with an additional one having no level set. This makes it super easy to migrate from the built-in "log"
package.
const (
PanicLevel Level = iota
FatalLevel
ErrorLevel
WarnLevel
NoLevel
InfoLevel
TraceLevel
DebugLevel
)
• Custom Log Layout
The layout can be modified according to the following table (you can use any combination):
Key | Maps to | Example |
---|---|---|
%y | Year | |
%M | Month | |
%d | Day | |
%h | Hours | |
%m | Minutes | |
%s | Seconds | |
%l | Log message | |
%L | Log level | |
%F | File path | /a/b/c/d.go |
%f | File name | d.go |
%i | Line in file | |
%D | %y/%M/%d | |
%T | %h:%m:%s |
NOTICE: If you doesn't call 'SetLayout', it will use
%D %T %L (%f:%i) ▶ %l
by default.
• Thread safety
Log is protected by a mutex, so you can output logs in multiple goroutines.
# Packages
No description provided by the author
# Functions
Debug is equivalent to Logger.Debug.
Debugf is equivalent to Logger.Debugf.
Error is equivalent to Logger.Error.
Errorf is equivalent to Logger.Errorf.
Fatal is equivalent to Logger.Fatal.
Fatalf is equivalent to Logger.Fatalf.
Info is equivalent to Logger.Info.
Infof is equivalent to Logger.Infof.
New creates a new Logger.
Panic is equivalent to Logger.Panic.
Panicf is equivalent to Logger.Panicf.
Printf is equivalent to Logger.Logf.
Println is equivalent to Logger.Log.
SetLevelDebug will set the log level to Debug.
SetLevelInfo will set the log level to Info.
SetOutput will set the output to the specified.
Trace is equivalent to Logger.Debug.
Tracef is equivalent to Logger.Debugf.
Warn is equivalent to Logger.Warn.
Warnf is equivalent to Logger.Warnf.