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
- func Crash(v ...interface{})
- func Crashf(format string, v ...interface{})
- func Exit(v ...interface{})
- func Exitf(format string, v ...interface{})
- func Stderr(v ...interface{})
- func Stderrf(format string, v ...interface{})
- func Stdout(v ...interface{})
- func Stdoutf(format string, v ...interface{})
- type Logger
Constants ¶
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).
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger represents an active logging object.
func New ¶
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.