log

package
v0.0.0-...-90c9d3a Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2010 License: BSD-3-Clause, GooglePatentClause Imports: 5 Imported by: 0

Documentation

Overview

Rudimentary logging package. Defines a type, Logger, with simple methods for formatting output to one or two destinations. Also has predefined Loggers accessible through helper functions Stdout[f], Stderr[f], Exit[f], and Crash[f], which are easier to use than creating a Logger manually. Exit exits when written to. Crash causes a crash when written to.

Index

Constants

View Source
const (
	// Flags
	Lok    = iota
	Lexit  // terminate execution when written
	Lcrash // crash (panic) when written
	// Bits or'ed together to control what's printed. There is no control over the
	// order they appear (the order listed here) or the format they present (as
	// described in the comments).  A colon appears after these items:
	//	2009/0123 01:23:23.123123 /a/b/c/d.go:23: message
	Ldate         = 1 << iota // the date: 2009/0123
	Ltime                     // the time: 01:23:23
	Lmicroseconds             // microsecond resolution: 01:23:23.123123.  assumes Ltime.
	Llongfile                 // full file name and line number: /a/b/c/d.go:23
	Lshortfile                // final file name element and line number: d.go:23. overrides Llongfile

)

These flags define the properties of the Logger and the output they produce.

Variables

This section is empty.

Functions

func Crash

func Crash(v ...interface{})

Crash is equivalent to Stderr() followed by a call to panic().

func Crashf

func Crashf(format string, v ...interface{})

Crashf is equivalent to Stderrf() followed by a call to panic().

func Exit

func Exit(v ...interface{})

Exit is equivalent to Stderr() followed by a call to os.Exit(1).

func Exitf

func Exitf(format string, v ...interface{})

Exitf is equivalent to Stderrf() followed by a call to os.Exit(1).

func Stderr

func Stderr(v ...interface{})

Stderr is a helper function for easy logging to stderr. It is analogous to Fprint(os.Stderr).

func Stderrf

func Stderrf(format string, v ...interface{})

Stderrf is a helper function for easy formatted logging to stderr. It is analogous to Fprintf(os.Stderr).

func Stdout

func Stdout(v ...interface{})

Stdout is a helper function for easy logging to stdout. It is analogous to Print().

func Stdoutf

func Stdoutf(format string, v ...interface{})

Stdoutf is a helper functions for easy formatted logging to stdout. It is analogous to Printf().

Types

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger represents an active logging object.

func New

func New(out0, out1 io.Writer, prefix string, flag int) *Logger

New creates a new Logger. The out0 and out1 variables set the destinations to which log data will be written; out1 may be nil. The prefix appears at the beginning of each generated log line. The flag argument defines the logging properties.

func (*Logger) Log

func (l *Logger) Log(v ...interface{})

Log is analogous to Print() for a Logger.

func (*Logger) Logf

func (l *Logger) Logf(format string, v ...interface{})

Logf is analogous to Printf() for a Logger.

func (*Logger) Output

func (l *Logger) Output(calldepth int, s string) os.Error

Output writes the output for a logging event. The string s contains the text to print after the time stamp; calldepth is used to recover the PC. It is provided for generality, although at the moment on all pre-defined paths it will be 2.

Jump to

Keyboard shortcuts

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