Documentation ¶
Overview ¶
FactorLog is a logging infrastructure for Go that provides numerous logging functions for whatever your style may be. It could easily be a replacement for Go's log in the standard library (though it doesn't support functions such as `SetFlags()`).
Basic usage:
import log "github.com/kdar/factorlog" log.Print("Hello there!")
Setting your own format:
import os import "github.com/kdar/factorlog" log := factorlog.New(os.Stdout, factorlog.NewStdFormatter("%{Date} %{Time} %{File}:%{Line} %{Message}")) log.Print("Hello there!")
Setting the verbosity and testing against it:
import os import "github.com/kdar/factorlog" log := factorlog.New(os.Stdout, factorlog.NewStdFormatter("%{Date} %{Time} %{File}:%{Line} %{Message}")) log.SetVerbosity(2) log.V(1).Print("Will print") log.V(3).Print("Will not print")
If you care about performance, you can test for verbosity this way:
if log.IsV(1) { log.Print("Hello there!") }
For more usage examples, check the examples/ directory.
Format verbs:
%{SEVERITY} - TRACE, DEBUG, INFO, WARN, ERROR, CRITICAL, STACK, FATAL, PANIC %{Severity} - Trace, Debug, Info, Warn, Error, Critical, Stack, Fatal, Panic %{severity} - trace, debug, info, warn, error, critical, stack, fatal, panic %{SEV} - TRAC, DEBG, INFO, WARN, EROR, CRIT, STAK, FATL, PANC %{Sev} - Trac, Debg, Info, Warn, Eror, Crit, Stak, Fatl, Panc %{sev} - trac, debg, info, warn, eror, crit, stak, fatl, panc %{S} - T, D, I, W, E, C, S, F, P %{s} - t, d, i, w, e, c, s, f, p %{Date} - Shorthand for 2006-01-02 %{Time} - Shorthand for 15:04:05 %{Time "<fmt>"} - Specify a format (read time.Format for details). Optimized formats: 2006/01/02, 15:04:05.000, 15:04:05.000000, 15:04:05.000000000 %{Unix} - Returns the number of seconds elapsed since January 1, 1970 UTC. %{UnixNano} - Returns the number of nanoseconds elapsed since January 1, 1970 UTC. %{FullFile} - Full source file path (e.g. /dev/project/file.go). %{File} - The source file name (e.g. file.go). %{ShortFile} - The short source file name (file without .go). %{Line} - The source line number. %{FullFunction} - The full source function including path. (e.g. /dev/project.(*Type).Function) %{PkgFunction} - The source package and function (e.g. project.(*Type).Function) %{Function} - The source function name (e.g. (*Type).Function) %{Color "<fmt>"} - Specify a color (uses https://github.com/mgutz/ansi) %{Color "<fmt>" "<severity>"} - Specify a color for a given severity (e.g. %{Color "red" "ERROR"}) %{Message} - The message. %{SafeMessage} - Safe message. It will escape any character below ASCII 32. This helps prevent attacks like using 0x08 to backspace log entries.
Example colors (see https://github.com/mgutz/ansi for more examples):
Added to mgutz/ansi: %{Color "reset"} - reset colors Supported by mgutz/ansi %{Color "red"} - red %{Color "red+b"} - red bold %{Color "red+B"} - red blinking %{Color "red+u"} - red underline %{Color "red+bh"} - red bold bright %{Color "red:white"} - red on white %{Color "red+b:white+h"} - red bold on white bright %{Color "red+B:white+h"} - red blink on white bright
All logging functions ending in "ln" are merely convenience functions and won't actually output another newline. This allows the formatters to handle a newline however they like (e.g. if you wanted to make a formatter that would output a streamed format without newlines).
Index ¶
- Variables
- func Critical(v ...interface{})
- func Criticalf(format string, v ...interface{})
- func Criticalln(v ...interface{})
- func Debug(v ...interface{})
- func Debugf(format string, v ...interface{})
- func Debugln(v ...interface{})
- func Error(v ...interface{})
- func Errorf(format string, v ...interface{})
- func Errorln(v ...interface{})
- func Fatal(v ...interface{})
- func Fatalf(format string, v ...interface{})
- func Fatalln(v ...interface{})
- func GetStack(calldepth int) []byte
- func I64toa(buf *[]byte, i int, d int64) int
- func Info(v ...interface{})
- func Infof(format string, v ...interface{})
- func Infoln(v ...interface{})
- func IsV(level Level) bool
- func Itoa(buf *[]byte, i, d int) int
- func Log(sev Severity, v ...interface{})
- func NDigits(buf *[]byte, n, i, d int)
- func Panic(v ...interface{})
- func Panicf(format string, v ...interface{})
- func Panicln(v ...interface{})
- func Print(v ...interface{})
- func Printf(format string, v ...interface{})
- func Println(v ...interface{})
- func SetFormatter(f Formatter)
- func SetMinMaxSeverity(min Severity, max Severity)
- func SetOutput(w io.Writer)
- func SetSeverities(sev Severity)
- func SetVerbosity(level Level)
- func SeverityToIndex(sev Severity) int
- func Stack(v ...interface{})
- func Stackf(format string, v ...interface{})
- func Stackln(v ...interface{})
- func Trace(v ...interface{})
- func Tracef(format string, v ...interface{})
- func Traceln(v ...interface{})
- func TwoDigits(buf *[]byte, i, d int)
- func Ui64toa(buf *[]byte, i int, d uint64) int
- func Warn(v ...interface{})
- func Warnf(format string, v ...interface{})
- func Warnln(v ...interface{})
- type FactorLog
- func (l *FactorLog) Critical(v ...interface{})
- func (l *FactorLog) Criticalf(format string, v ...interface{})
- func (l *FactorLog) Criticalln(v ...interface{})
- func (l *FactorLog) Debug(v ...interface{})
- func (l *FactorLog) Debugf(format string, v ...interface{})
- func (l *FactorLog) Debugln(v ...interface{})
- func (l *FactorLog) Error(v ...interface{})
- func (l *FactorLog) Errorf(format string, v ...interface{})
- func (l *FactorLog) Errorln(v ...interface{})
- func (l *FactorLog) Fatal(v ...interface{})
- func (l *FactorLog) Fatalf(format string, v ...interface{})
- func (l *FactorLog) Fatalln(v ...interface{})
- func (l *FactorLog) Info(v ...interface{})
- func (l *FactorLog) Infof(format string, v ...interface{})
- func (l *FactorLog) Infoln(v ...interface{})
- func (l *FactorLog) IsV(level Level) bool
- func (l *FactorLog) Log(sev Severity, v ...interface{})
- func (l *FactorLog) Output(sev Severity, calldepth int, v ...interface{}) error
- func (l *FactorLog) Panic(v ...interface{})
- func (l *FactorLog) Panicf(format string, v ...interface{})
- func (l *FactorLog) Panicln(v ...interface{})
- func (l *FactorLog) Print(v ...interface{})
- func (l *FactorLog) Printf(format string, v ...interface{})
- func (l *FactorLog) Println(v ...interface{})
- func (l *FactorLog) SetFormatter(f Formatter)
- func (l *FactorLog) SetMinMaxSeverity(min Severity, max Severity)
- func (l *FactorLog) SetOutput(w io.Writer)
- func (l *FactorLog) SetSeverities(sev Severity)
- func (l *FactorLog) SetVerbosity(level Level)
- func (l *FactorLog) Stack(v ...interface{})
- func (l *FactorLog) Stackf(format string, v ...interface{})
- func (l *FactorLog) Stackln(v ...interface{})
- func (l *FactorLog) Trace(v ...interface{})
- func (l *FactorLog) Tracef(format string, v ...interface{})
- func (l *FactorLog) Traceln(v ...interface{})
- func (l *FactorLog) V(level Level) Verbose
- func (l *FactorLog) Warn(v ...interface{})
- func (l *FactorLog) Warnf(format string, v ...interface{})
- func (l *FactorLog) Warnln(v ...interface{})
- type Formatter
- type Level
- type LogContext
- type Logger
- type NullLogger
- func (NullLogger) Critical(v ...interface{})
- func (NullLogger) Criticalf(format string, v ...interface{})
- func (NullLogger) Criticalln(v ...interface{})
- func (NullLogger) Debug(v ...interface{})
- func (NullLogger) Debugf(format string, v ...interface{})
- func (NullLogger) Debugln(v ...interface{})
- func (NullLogger) Error(v ...interface{})
- func (NullLogger) Errorf(format string, v ...interface{})
- func (NullLogger) Errorln(v ...interface{})
- func (NullLogger) Fatal(v ...interface{})
- func (NullLogger) Fatalf(format string, v ...interface{})
- func (NullLogger) Fatalln(v ...interface{})
- func (NullLogger) Info(v ...interface{})
- func (NullLogger) Infof(format string, v ...interface{})
- func (NullLogger) Infoln(v ...interface{})
- func (NullLogger) IsV(level Level) bool
- func (NullLogger) Log(sev Severity, v ...interface{})
- func (NullLogger) Output(sev Severity, calldepth int, v ...interface{}) error
- func (NullLogger) Panic(v ...interface{})
- func (NullLogger) Panicf(format string, v ...interface{})
- func (NullLogger) Panicln(v ...interface{})
- func (NullLogger) Print(v ...interface{})
- func (NullLogger) Printf(format string, v ...interface{})
- func (NullLogger) Println(v ...interface{})
- func (NullLogger) SetVerbosity(level Level)
- func (NullLogger) Stack(v ...interface{})
- func (NullLogger) Stackf(format string, v ...interface{})
- func (NullLogger) Stackln(v ...interface{})
- func (NullLogger) Trace(v ...interface{})
- func (NullLogger) Tracef(format string, v ...interface{})
- func (NullLogger) Traceln(v ...interface{})
- func (NullLogger) V(level Level) Verbose
- func (NullLogger) Warn(v ...interface{})
- func (NullLogger) Warnf(format string, v ...interface{})
- func (NullLogger) Warnln(v ...interface{})
- type Severity
- type StdFormatter
- type Verbose
- func (b Verbose) Critical(v ...interface{})
- func (b Verbose) Criticalf(format string, v ...interface{})
- func (b Verbose) Criticalln(v ...interface{})
- func (b Verbose) Debug(v ...interface{})
- func (b Verbose) Debugf(format string, v ...interface{})
- func (b Verbose) Debugln(v ...interface{})
- func (b Verbose) Error(v ...interface{})
- func (b Verbose) Errorf(format string, v ...interface{})
- func (b Verbose) Errorln(v ...interface{})
- func (b Verbose) Fatal(v ...interface{})
- func (b Verbose) Fatalf(format string, v ...interface{})
- func (b Verbose) Fatalln(v ...interface{})
- func (b Verbose) Info(v ...interface{})
- func (b Verbose) Infof(format string, v ...interface{})
- func (b Verbose) Infoln(v ...interface{})
- func (b Verbose) IsV(level Level) bool
- func (b Verbose) Log(sev Severity, v ...interface{})
- func (b Verbose) Output(sev Severity, calldepth int, v ...interface{}) error
- func (b Verbose) Panic(v ...interface{})
- func (b Verbose) Panicf(format string, v ...interface{})
- func (b Verbose) Panicln(v ...interface{})
- func (b Verbose) Print(v ...interface{})
- func (b Verbose) Printf(format string, v ...interface{})
- func (b Verbose) Println(v ...interface{})
- func (b Verbose) SetVerbosity(level Level)
- func (b Verbose) Stack(v ...interface{})
- func (b Verbose) Stackf(format string, v ...interface{})
- func (b Verbose) Stackln(v ...interface{})
- func (b Verbose) Trace(v ...interface{})
- func (b Verbose) Tracef(format string, v ...interface{})
- func (b Verbose) Traceln(v ...interface{})
- func (b Verbose) V(level Level) Verbose
- func (b Verbose) Warn(v ...interface{})
- func (b Verbose) Warnf(format string, v ...interface{})
- func (b Verbose) Warnln(v ...interface{})
Constants ¶
This section is empty.
Variables ¶
var CapSeverityStrings = [...]string{
"None",
"Trace",
"Debug",
"Info",
"Warn",
"Error",
"Critical",
"Stack",
"Fatal",
"Panic",
}
var CapShortSeverityStrings = [...]string{
"None",
"Trac",
"Debg",
"Info",
"Warn",
"Eror",
"Crit",
"Stak",
"Fatl",
"Panc",
}
var LcSeverityStrings = [...]string{
"none",
"trace",
"debug",
"info",
"warn",
"error",
"critical",
"stack",
"fatal",
"panic",
}
var LcShortSeverityStrings = [...]string{
"none",
"trac",
"debg",
"info",
"warn",
"eror",
"crit",
"stak",
"fatl",
"panc",
}
var LcShortestSeverityStrings = [...]string{
"n",
"t",
"d",
"i",
"w",
"e",
"c",
"s",
"f",
"p",
}
var UcSeverityStrings = [...]string{
"NONE",
"TRACE",
"DEBUG",
"INFO",
"WARN",
"ERROR",
"CRITICAL",
"STACK",
"FATAL",
"PANIC",
}
var UcShortSeverityStrings = [...]string{
"NONE",
"TRAC",
"DEBG",
"INFO",
"WARN",
"EROR",
"CRIT",
"STAK",
"FATL",
"PANC",
}
var UcShortestSeverityStrings = [...]string{
"",
"T",
"D",
"I",
"W",
"E",
"C",
"S",
"F",
"P",
}
Functions ¶
func Criticalln ¶
func Criticalln(v ...interface{})
func Itoa ¶
itoa converts an integer d to its ascii representation i is the deintation index in buf algorithm from https://www.facebook.com/notes/facebook-engineering/three-optimization-tips-for-c/10151361643253920
func NDigits ¶
nDigits converts an integer d to its ascii representation n is how many digits to use i is the destination index in buf
func SetFormatter ¶
func SetFormatter(f Formatter)
SetFormatter sets the formatter for the standard logger.
func SetMinMaxSeverity ¶
func SetSeverities ¶
func SetSeverities(sev Severity)
func SetVerbosity ¶
func SetVerbosity(level Level)
func SeverityToIndex ¶
We use this function to convert a severity to an index that we can then use to index variables like UcSeverityStrings. Why don't we use maps? This is almost 3x faster.
func TwoDigits ¶
twoDigits converts an integer d to its ascii representation i is the destination index in buf
Types ¶
type FactorLog ¶
type FactorLog struct {
// contains filtered or unexported fields
}
FactorLog is a logging object that outputs data to an io.Writer. Each write is threadsafe.
func (*FactorLog) Critical ¶
func (l *FactorLog) Critical(v ...interface{})
Critical is equivalent to Print with severity CRITICAL.
func (*FactorLog) Criticalln ¶
func (l *FactorLog) Criticalln(v ...interface{})
Criticalln is equivalent to Println with severity CRITICAL.
func (*FactorLog) Debug ¶
func (l *FactorLog) Debug(v ...interface{})
Debug is equivalent to Print with severity DEBUG.
func (*FactorLog) Debugln ¶
func (l *FactorLog) Debugln(v ...interface{})
Debugln is equivalent to Println with severity DEBUG.
func (*FactorLog) Error ¶
func (l *FactorLog) Error(v ...interface{})
Error is equivalent to Print with severity ERROR.
func (*FactorLog) Errorln ¶
func (l *FactorLog) Errorln(v ...interface{})
Errorln is equivalent to Println with severity ERROR.
func (*FactorLog) Fatal ¶
func (l *FactorLog) Fatal(v ...interface{})
Fatal is equivalent to Print() followed by a call to os.Exit(1).
func (*FactorLog) Fatalln ¶
func (l *FactorLog) Fatalln(v ...interface{})
Fatalln is equivalent to Println() followed by a call to os.Exit(1).
func (*FactorLog) Info ¶
func (l *FactorLog) Info(v ...interface{})
Info is equivalent to Print with severity INFO.
func (*FactorLog) Infoln ¶
func (l *FactorLog) Infoln(v ...interface{})
Infoln is equivalent to Println with severity INFO.
func (*FactorLog) IsV ¶
IsV tests whether the verbosity is of a certain level. Returns a bool. Example:
if log.IsV(2) { log.Info("some info") }
func (*FactorLog) Output ¶
Output will write to the writer with the given severity, calldepth, and string. calldepth is only used if the format requires a call to runtime.Caller.
func (*FactorLog) Panic ¶
func (l *FactorLog) Panic(v ...interface{})
Panic is equivalent to Print() followed by a call to panic().
func (*FactorLog) Panicln ¶
func (l *FactorLog) Panicln(v ...interface{})
Panicf is equivalent to Printf() followed by a call to panic().
func (*FactorLog) Print ¶
func (l *FactorLog) Print(v ...interface{})
Print calls l.output to print to the logger. Uses fmt.Sprint.
func (*FactorLog) Println ¶
func (l *FactorLog) Println(v ...interface{})
Println calls l.output to print to the logger. Uses fmt.Sprint. This is more of a convenience function. If you really want to output an extra newline at the end, just append \n.
func (*FactorLog) SetFormatter ¶
SetFormatter sets the formatter for this logger.
func (*FactorLog) SetMinMaxSeverity ¶
SetMinMaxSeverity sets the minimum and maximum severities this log will output for. Example:
l.SetMinMaxSeverity(INFO, ERROR)
func (*FactorLog) SetSeverities ¶
SetSeverities sets which severities this log will output for. Example:
l.SetSeverities(INFO|DEBUG)
func (*FactorLog) SetVerbosity ¶
Sets the verbosity level of this log. Use IsV() or V() to utilize verbosity.
func (*FactorLog) Stack ¶
func (l *FactorLog) Stack(v ...interface{})
Stack is equivalent to Print() followed by printing a stack trace to the configured writer.
func (*FactorLog) Stackf ¶
Stackf is equivalent to Printf() followed by printing a stack trace to the configured writer.
func (*FactorLog) Stackln ¶
func (l *FactorLog) Stackln(v ...interface{})
Stackln is equivalent to Println() followed by printing a stack trace to the configured writer.
func (*FactorLog) Trace ¶
func (l *FactorLog) Trace(v ...interface{})
Trace is equivalent to Print with severity TRACE.
func (*FactorLog) Traceln ¶
func (l *FactorLog) Traceln(v ...interface{})
Traceln is equivalent to Println with severity TRACE.
func (*FactorLog) V ¶
V tests whether the verbosity is of a certain level, and returns a Verbose object that allows you to chain calls. This is a convenience function and should be avoided if you care about raw performance (use IsV() instead). Example:
log.V(2).Info("some info")
func (*FactorLog) Warn ¶
func (l *FactorLog) Warn(v ...interface{})
Warn is equivalent to Print with severity WARN.
type Formatter ¶
type Formatter interface { // Formats LogRecord and returns the []byte that will // be written by the log. This is not inherently thread // safe but FactorLog uses a mutex before calling this. Format(context LogContext) []byte // Returns true if we should call runtime.Caller because // we have a format that requires it. We do this because // it is expensive. ShouldRuntimeCaller() bool }
Interface to format anything
type LogContext ¶
type LogContext struct { Time time.Time Severity Severity File string Line int Function string Pid int Format *string Args []interface{} }
Structure used to hold the data used for formatting
type Logger ¶
type Logger interface { Output(sev Severity, calldepth int, v ...interface{}) error Trace(v ...interface{}) Tracef(format string, v ...interface{}) Traceln(v ...interface{}) Debug(v ...interface{}) Debugf(format string, v ...interface{}) Debugln(v ...interface{}) Info(v ...interface{}) Infof(format string, v ...interface{}) Infoln(v ...interface{}) Warn(v ...interface{}) Warnf(format string, v ...interface{}) Warnln(v ...interface{}) Error(v ...interface{}) Errorf(format string, v ...interface{}) Errorln(v ...interface{}) Critical(v ...interface{}) Criticalf(format string, v ...interface{}) Criticalln(v ...interface{}) Stack(v ...interface{}) Stackf(format string, v ...interface{}) Stackln(v ...interface{}) Log(sev Severity, v ...interface{}) //Log verbosity V(level Level) Verbose SetVerbosity(level Level) IsV(level Level) bool // golang's log interface Print(v ...interface{}) Printf(format string, v ...interface{}) Println(v ...interface{}) Fatal(v ...interface{}) Fatalf(format string, v ...interface{}) Fatalln(v ...interface{}) Panic(v ...interface{}) Panicf(format string, v ...interface{}) Panicln(v ...interface{}) }
type NullLogger ¶
type NullLogger struct{}
Creates a logger that outputs to nothing
func (NullLogger) Critical ¶
func (NullLogger) Critical(v ...interface{})
func (NullLogger) Criticalf ¶
func (NullLogger) Criticalf(format string, v ...interface{})
func (NullLogger) Criticalln ¶
func (NullLogger) Criticalln(v ...interface{})
func (NullLogger) Debug ¶
func (NullLogger) Debug(v ...interface{})
func (NullLogger) Debugf ¶
func (NullLogger) Debugf(format string, v ...interface{})
func (NullLogger) Debugln ¶
func (NullLogger) Debugln(v ...interface{})
func (NullLogger) Error ¶
func (NullLogger) Error(v ...interface{})
func (NullLogger) Errorf ¶
func (NullLogger) Errorf(format string, v ...interface{})
func (NullLogger) Errorln ¶
func (NullLogger) Errorln(v ...interface{})
func (NullLogger) Fatal ¶
func (NullLogger) Fatal(v ...interface{})
func (NullLogger) Fatalf ¶
func (NullLogger) Fatalf(format string, v ...interface{})
func (NullLogger) Fatalln ¶
func (NullLogger) Fatalln(v ...interface{})
func (NullLogger) Info ¶
func (NullLogger) Info(v ...interface{})
func (NullLogger) Infof ¶
func (NullLogger) Infof(format string, v ...interface{})
func (NullLogger) Infoln ¶
func (NullLogger) Infoln(v ...interface{})
func (NullLogger) IsV ¶
func (NullLogger) IsV(level Level) bool
func (NullLogger) Log ¶
func (NullLogger) Log(sev Severity, v ...interface{})
func (NullLogger) Output ¶
func (NullLogger) Output(sev Severity, calldepth int, v ...interface{}) error
func (NullLogger) Panic ¶
func (NullLogger) Panic(v ...interface{})
func (NullLogger) Panicf ¶
func (NullLogger) Panicf(format string, v ...interface{})
func (NullLogger) Panicln ¶
func (NullLogger) Panicln(v ...interface{})
func (NullLogger) Print ¶
func (NullLogger) Print(v ...interface{})
func (NullLogger) Printf ¶
func (NullLogger) Printf(format string, v ...interface{})
func (NullLogger) Println ¶
func (NullLogger) Println(v ...interface{})
func (NullLogger) SetVerbosity ¶
func (NullLogger) SetVerbosity(level Level)
func (NullLogger) Stack ¶
func (NullLogger) Stack(v ...interface{})
func (NullLogger) Stackf ¶
func (NullLogger) Stackf(format string, v ...interface{})
func (NullLogger) Stackln ¶
func (NullLogger) Stackln(v ...interface{})
func (NullLogger) Trace ¶
func (NullLogger) Trace(v ...interface{})
func (NullLogger) Tracef ¶
func (NullLogger) Tracef(format string, v ...interface{})
func (NullLogger) Traceln ¶
func (NullLogger) Traceln(v ...interface{})
func (NullLogger) V ¶
func (NullLogger) V(level Level) Verbose
func (NullLogger) Warn ¶
func (NullLogger) Warn(v ...interface{})
func (NullLogger) Warnf ¶
func (NullLogger) Warnf(format string, v ...interface{})
func (NullLogger) Warnln ¶
func (NullLogger) Warnln(v ...interface{})
type Severity ¶
type Severity int32
Severity represents the severity of the log.
func StringToSeverity ¶
Convert an uppercase string to a severity.
type StdFormatter ¶
type StdFormatter struct {
// contains filtered or unexported fields
}
func NewStdFormatter ¶
func NewStdFormatter(frmt string) *StdFormatter
Available verbs:
%{SEVERITY} - TRACE, DEBUG, INFO, WARN, ERROR, CRITICAL, STACK, FATAL, PANIC %{Severity} - Trace, Debug, Info, Warn, Error, Critical, Stack, Fatal, Panic %{severity} - trace, debug, info, warn, error, critical, stack, fatal, panic %{SEV} - TRAC, DEBG, INFO, WARN, EROR, CRIT, STAK, FATL, PANC %{Sev} - Trac, Debg, Info, Warn, Eror, Crit, Stak, Fatl, Panc %{sev} - trac, debg, info, warn, eror, crit, stak, fatl, panc %{S} - T, D, I, W, E, C, S, F, P %{s} - t, d, i, w, e, c, s, f, p %{Date} - Shorthand for 2006-01-02 %{Time} - Shorthand for 15:04:05 %{Time "<fmt>"} - Specify a format (read time.Format for details). Optimized formats: 2006/01/02, 15:04:05.000, 15:04:05.000000, 15:04:05.000000000 %{Unix} - Returns the number of seconds elapsed since January 1, 1970 UTC. %{UnixNano} - Returns the number of nanoseconds elapsed since January 1, 1970 UTC. %{FullFile} - Full source file path (e.g. /dev/project/file.go). %{File} - The source file name (e.g. file.go). %{ShortFile} - The short source file name (file without .go). %{Line} - The source line number. %{FullFunction} - The full source function including path. (e.g. /dev/project.(*Type).Function) %{PkgFunction} - The source package and function (e.g. project.(*Type).Function) %{Function} - The source function name (e.g. (*Type).Function) %{Color "<fmt>"} - Specify a color (uses https://github.com/mgutz/ansi) %{Color "<fmt>" "<severity>"} - Specify a color for a given severity (e.g. %{Color "red" "ERROR"}) %{Message} - The message. %{SafeMessage} - Safe message. It will escape any character below ASCII 32. This helps prevent attacks like using 0x08 to backspace log entries.
func (*StdFormatter) Format ¶
func (f *StdFormatter) Format(context LogContext) []byte
func (*StdFormatter) ShouldRuntimeCaller ¶
func (f *StdFormatter) ShouldRuntimeCaller() bool
type Verbose ¶
type Verbose struct { True bool // contains filtered or unexported fields }
Verbose is a structure that enables syntatic sugar when testing for verbosity and calling a log function. See FactorLog.V().
func (Verbose) Criticalln ¶
func (b Verbose) Criticalln(v ...interface{})