Documentation ¶
Index ¶
- Variables
- func Error(args ...interface{})
- func Errorf(format string, args ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(format string, args ...interface{})
- func Info(args ...interface{})
- func Infof(format string, args ...interface{})
- func Setup(settings Settings)
- func Warn(args ...interface{})
- func Warnf(format string, args ...interface{})
- type Entry
- type Frame
- type Settings
Constants ¶
This section is empty.
Variables ¶
var FilterStackTrace = func(filename string) bool { return strings.HasSuffix(filename, ".s") || strings.HasPrefix(filename, "http/server.go") || strings.HasPrefix(filename, "runtime/proc.go") || filename == "testing/testing.go" }
FilterStackTrace is called by the StackTrace function to filter frames. This variable can be set to a custom function.
Functions ¶
func Errorf ¶
func Errorf(format string, args ...interface{})
Errorf logs an Entry with a status of "error"
func Fatal ¶
func Fatal(args ...interface{})
Fatal logs an Entry with a status of "fatal" and exits the program with status code 1.
func Fatalf ¶
func Fatalf(format string, args ...interface{})
Fatalf logs an Entry with a status of "fatal" and exits the program with status code 1.
func Infof ¶
func Infof(format string, args ...interface{})
Infof logs an Entry with a status of "info"
Types ¶
type Entry ¶
type Entry interface { // AddField adds a single field to the Entry. AddField(key string, value interface{}) // AddFields adds a map of fields to the Entry. AddFields(fields map[string]interface{}) // Info logs the Entry with a status of "info". Info(args ...interface{}) // Infof logs the Entry with a status of "info". Infof(format string, args ...interface{}) // Warn logs the Entry with a status of "warn". Warn(args ...interface{}) // Warnf logs the Entry with a status of "warn". Warnf(format string, args ...interface{}) // Error logs the Entry with a status of "error". Error(args ...interface{}) // Errorf logs the Entry with a status of "error". Errorf(format string, args ...interface{}) // Fatal logs the Entry with a status of "fatal" and calls os.Exit(1). Fatal(args ...interface{}) // Fatalf logs the Entry with a status of "fatal" and calls os.Exit(1). Fatalf(format string, args ...interface{}) // AddError adds a field "err" with the specified error. AddError(err error) String() string }
Entry is the interface returned by NewEntry.
Use AddField or AddFields (opposed to Logrus' WithField) to add new fields to an entry.
To add source file and line information call AddCallstack.
Call the Info, Warn, Error, or Fatal methods to write the log entry.
type Frame ¶
Frame contains information about a stack trace frame.
func StackTrace ¶
StackTrace returns the stack frames of an error created by github.com/pkg/errors. This function calls httplog.FilterStackTrace to filter frames.
type Settings ¶
type Settings struct { // WriteStdout determines if the log will be written to Stdout. The default // is to only write to the log file. When running as a Windows Service make // sure not to write to Stdout. WriteStdout bool // Filename is the file to write logs to. Backup log files will be retained // in the same directory. It uses <processpath>/logs/<processname>.log if empty. Filename string `json:"filename" yaml:"filename"` // MaxSizeMB is the maximum size in megabytes of the log file before it gets // rotated. It defaults to 100 megabytes. MaxSizeMB int `json:"maxsize" yaml:"maxsize"` // MaxAgeDays is the maximum number of days to retain old log files based on the // timestamp encoded in their filename. Note that a day is defined as 24 // hours and may not exactly correspond to calendar days due to daylight // savings, leap seconds, etc. The default is not to remove old log files // based on age. MaxAgeDays int `json:"maxage" yaml:"maxage"` // MaxBackups is the maximum number of old log files to retain. The default // is to retain all old log files (though MaxAgeDays may still cause them to get // deleted.) MaxBackups int `json:"maxbackups" yaml:"maxbackups"` // LocalTime determines if the time used for formatting the timestamps in // backup files is the computer's local time. The default is to use UTC // time. LocalTime bool `json:"localtime" yaml:"localtime"` }
Settings specifies the options used to initialize Logrus and Lumberjack.