Documentation ¶
Overview ¶
Package log implements leveled logging. Although the API is inspired by https://github.com/golang/glog which aims to be analogous to the Google-internal C++ INFO/ERROR/V setup the behavior is different.
It provides functions Info, Warning, Error, Fatal, plus formatting variants such as Infof. These functions are protected by the verbosity set via the -v flag. All logs are sent to standard error.
Basic examples:
log.Info("Prepare to repel boarders") log.Fatalf("Initialization failed: %s", err)
All log statements are written to standard error. This package uses flags for configuration. As a result, flag.Parse must be called.
-log_backtrace_at="" When set to a file and line number holding a logging statement, such as -log_backtrace_at=gopherflakes.go:234 a stack trace will be written to the Info log whenever execution hits that statement. (Unlike with -vmodule, the ".go" must be present.) -v="info" Enable logging at the specified level and above.
Index ¶
- Variables
- func Atrace(ln string)
- func Debug(args ...interface{})
- func DebugDepth(depth int, args ...interface{})
- func Debugf(format string, args ...interface{})
- func Debugln(args ...interface{})
- func Error(args ...interface{})
- func ErrorDepth(depth int, args ...interface{})
- func Errorf(format string, args ...interface{})
- func Errorln(args ...interface{})
- func Fatal(args ...interface{})
- func FatalDepth(depth int, args ...interface{})
- func Fatalf(format string, args ...interface{})
- func Fatalln(args ...interface{})
- func Info(args ...interface{})
- func InfoDepth(depth int, args ...interface{})
- func Infof(format string, args ...interface{})
- func Infoln(args ...interface{})
- func Trace(args ...interface{})
- func TraceDepth(depth int, args ...interface{})
- func Tracef(format string, args ...interface{})
- func Traceln(args ...interface{})
- func Version(revision string)
- func Warning(args ...interface{})
- func WarningDepth(depth int, args ...interface{})
- func Warningf(format string, args ...interface{})
- func Warningln(args ...interface{})
- type OutputStats
Constants ¶
This section is empty.
Variables ¶
var Stats struct { Trace, Debug, Info, Warning, Error OutputStats }
Stats tracks the number of lines of output and number of bytes per severity level. Values must be read with atomic.LoadInt64.
Functions ¶
func DebugDepth ¶
func DebugDepth(depth int, args ...interface{})
func ErrorDepth ¶
func ErrorDepth(depth int, args ...interface{})
func FatalDepth ¶
func FatalDepth(depth int, args ...interface{})
func TraceDepth ¶
func TraceDepth(depth int, args ...interface{})
func WarningDepth ¶
func WarningDepth(depth int, args ...interface{})
Types ¶
type OutputStats ¶
type OutputStats struct {
// contains filtered or unexported fields
}
OutputStats tracks the number of output lines and bytes written.
func (*OutputStats) Bytes ¶
func (s *OutputStats) Bytes() int64
Bytes returns the number of bytes written.
func (*OutputStats) Lines ¶
func (s *OutputStats) Lines() int64
Lines returns the number of lines written.