Documentation
¶
Index ¶
- Constants
- Variables
- func CallerFile(l *Logger)
- func CallerFunc(l *Logger)
- func CallerPkg(l *Logger)
- func Debug(l *Logger)
- func Fatalf(format string, args ...interface{})
- func LevelBraces(l *Logger)
- func Msec(l *Logger)
- func Print(line string)
- func Printf(format string, args ...interface{})
- func Setup(opts ...Option)
- func ToStdLogger(l L, level string) *log.Logger
- func Trace(l *Logger)
- type Func
- type L
- type Logger
- type Option
- type Writer
Constants ¶
const ( Short = `{{.DT.Format "2006/01/02 15:04:05"}} {{.Level}} {{.Message}}` WithMsec = `{{.DT.Format "2006/01/02 15:04:05.000"}} {{.Level}} {{.Message}}` WithPkg = `{{.DT.Format "2006/01/02 15:04:05.000"}} {{.Level}} ({{.CallerPkg}}) {{.Message}}` ShortDebug = `{{.DT.Format "2006/01/02 15:04:05.000"}} {{.Level}} ({{.CallerFile}}:{{.CallerLine}}) {{.Message}}` FuncDebug = `{{.DT.Format "2006/01/02 15:04:05.000"}} {{.Level}} ({{.CallerFunc}}) {{.Message}}` FullDebug = `{{.DT.Format "2006/01/02 15:04:05.000"}} {{.Level}} ({{.CallerFile}}:{{.CallerLine}} {{.CallerFunc}}) {{.Message}}` )
Variables ¶
var NoOp = Func(func(format string, args ...interface{}) {})
NoOp logger
var Std = Func(func(format string, args ...interface{}) { stdlog.Printf(format, args...) })
Std logger sends to std default logger directly
Functions ¶
func CallerFile ¶ added in v0.1.4
func CallerFile(l *Logger)
CallerFile adds caller info with file, and line number. Ignored if Format option used.
func CallerFunc ¶ added in v0.1.4
func CallerFunc(l *Logger)
CallerFunc adds caller info with function name. Ignored if Format option used.
func CallerPkg ¶ added in v0.3.0
func CallerPkg(l *Logger)
CallerPkg adds caller's package name. Ignored if Format option used.
func Fatalf ¶ added in v0.2.0
func Fatalf(format string, args ...interface{})
Fatalf simplifies replacement of std logger
func LevelBraces ¶ added in v0.1.4
func LevelBraces(l *Logger)
LevelBraces surrounds level with [], i.e. [INFO]. Ignored if Format option used.
func Msec ¶ added in v0.2.0
func Msec(l *Logger)
Msec adds .msec to timestamp. Ignored if Format option used.
Types ¶
type Func ¶
type Func func(format string, args ...interface{})
Func type is an adapter to allow the use of ordinary functions as Logger.
type L ¶
type L interface {
Logf(format string, args ...interface{})
}
L defines minimal interface used to log things
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger provided simple logger with basic support of levels. Thread safe
func New ¶
New makes new leveled logger. By default writes to stdout/stderr. default format: 2018/01/07 13:02:34.123 DEBUG some message 123
type Option ¶
type Option func(l *Logger)
Option func type
func CallerDepth ¶ added in v0.5.0
CallerDepth sets number of stack frame skipped for caller reporting, 0 by default