golog

package
v0.0.0-...-8b1022e Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2016 License: Apache-2.0, Apache-2.0 Imports: 18 Imported by: 0

README

golog Travis CI Status Coverage Status GoDoc

Provides logging used in many getlantern components.

GoDoc

Documentation

Overview

Package golog implements logging functions that log errors to stderr and debug messages to stdout. Trace logging is also supported. Trace logs go to stdout as well, but they are only written if the program is run with environment variable "TRACE=true". A stack dump will be printed after the message if "PRINT_STACK=true".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetOutputs

func GetOutputs() *outputs

func RegisterReporter

func RegisterReporter(reporter ErrorReporter)

RegisterReporter registers the given ErrorReporter. All logged Errors are sent to this reporter.

func ResetOutputs

func ResetOutputs()

func SetOutputs

func SetOutputs(errorOut io.Writer, debugOut io.Writer)

Types

type ErrorReporter

type ErrorReporter func(err error, logText string, ctx map[string]interface{})

ErrorReporter is a function to which the logger will report errors. It the given error and corresponding logText along with associated ops context. This should return quickly as it executes on the critical code path. The recommended approach is to buffer as much as possible and discard new reports if the buffer becomes saturated.

type Logger

type Logger interface {
	// Debug logs to stdout
	Debug(arg interface{})
	// Debugf logs to stdout
	Debugf(message string, args ...interface{})

	// Error logs to stderr
	Error(arg interface{}) error
	// Errorf logs to stderr. It returns the first argument that's an error, or
	// a new error built using fmt.Errorf if none of the arguments are errors.
	Errorf(message string, args ...interface{}) error

	// Fatal logs to stderr and then exits with status 1
	Fatal(arg interface{})
	// Fatalf logs to stderr and then exits with status 1
	Fatalf(message string, args ...interface{})

	// Trace logs to stderr only if TRACE=true
	Trace(arg interface{})
	// Tracef logs to stderr only if TRACE=true
	Tracef(message string, args ...interface{})

	// TraceOut provides access to an io.Writer to which trace information can
	// be streamed. If running with environment variable "TRACE=true", TraceOut
	// will point to os.Stderr, otherwise it will point to a ioutil.Discared.
	// Each line of trace information will be prefixed with this Logger's
	// prefix.
	TraceOut() io.Writer

	// IsTraceEnabled() indicates whether or not tracing is enabled for this
	// logger.
	IsTraceEnabled() bool

	// AsStdLogger returns an standard logger
	AsStdLogger() *log.Logger
}

func LoggerFor

func LoggerFor(prefix string) Logger

type MultiLine

type MultiLine interface {
	// MultiLinePrinter returns a function that can be used to print the
	// multi-line output. The returned function writes one line to the buffer and
	// returns true if there are more lines to write. This function does not need
	// to take care of trailing carriage returns, golog handles that
	// automatically.
	MultiLinePrinter() func(buf *bytes.Buffer) bool
}

MultiLine is an interface for arguments that support multi-line output.

Jump to

Keyboard shortcuts

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