log

package
v0.0.0-...-60a913f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2015 License: BSD-2-Clause Imports: 11 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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 Atrace

func Atrace(ln string)

func Debug

func Debug(args ...interface{})

func DebugDepth

func DebugDepth(depth int, args ...interface{})

func Debugf

func Debugf(format string, args ...interface{})

func Debugln

func Debugln(args ...interface{})

func Error

func Error(args ...interface{})

func ErrorDepth

func ErrorDepth(depth int, args ...interface{})

func Errorf

func Errorf(format string, args ...interface{})

func Errorln

func Errorln(args ...interface{})

func Fatal

func Fatal(args ...interface{})

func FatalDepth

func FatalDepth(depth int, args ...interface{})

func Fatalf

func Fatalf(format string, args ...interface{})

func Fatalln

func Fatalln(args ...interface{})

func Info

func Info(args ...interface{})

func InfoDepth

func InfoDepth(depth int, args ...interface{})

func Infof

func Infof(format string, args ...interface{})

func Infoln

func Infoln(args ...interface{})

func Trace

func Trace(args ...interface{})

func TraceDepth

func TraceDepth(depth int, args ...interface{})

func Tracef

func Tracef(format string, args ...interface{})

func Traceln

func Traceln(args ...interface{})

func Version

func Version(revision string)

func Warning

func Warning(args ...interface{})

func WarningDepth

func WarningDepth(depth int, args ...interface{})

func Warningf

func Warningf(format string, args ...interface{})

func Warningln

func Warningln(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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL