Documentation
¶
Overview ¶
Package flog provides a logging facility with the usual syslog-style levels of Critical, Error, Warning, Info, and Debug. It just uses os.Stderr and os.Stdout by default, and it's mostly here to provide a quick, easy, yet replaceable way to do logging.
Index ¶
- Variables
- func CriticalPrintf(format string, args ...interface{})
- func CriticalPrintln(args ...interface{})
- func DebugPrintf(format string, args ...interface{})
- func DebugPrintln(args ...interface{})
- func ErrorPrintf(format string, args ...interface{})
- func ErrorPrintln(args ...interface{})
- func InfoPrintf(format string, args ...interface{})
- func InfoPrintln(args ...interface{})
- func WarningPrintf(format string, args ...interface{})
- func WarningPrintln(args ...interface{})
- type Config
- type Flog
- type Logger
Constants ¶
This section is empty.
Variables ¶
var Default = New(nil)
Default is an instance of Flog for ease of use. Though I'd recommend writing your code to accept a Flog or Logger so others can alter it later; this Default can be changed to indirectly have a similar effect.
Functions ¶
func CriticalPrintf ¶
func CriticalPrintf(format string, args ...interface{})
CriticalPrintf is a convenience function equivalent to Default.CriticalPrintf.
func CriticalPrintln ¶
func CriticalPrintln(args ...interface{})
CriticalPrintln is a convenience function equivalent to Default.CriticalPrintln.
func DebugPrintf ¶
func DebugPrintf(format string, args ...interface{})
DebugPrintf is a convenience function equivalent to Default.DebugPrintf.
func DebugPrintln ¶
func DebugPrintln(args ...interface{})
DebugPrintln is a convenience function equivalent to Default.DebugPrintln.
func ErrorPrintf ¶
func ErrorPrintf(format string, args ...interface{})
ErrorPrintf is a convenience function equivalent to Default.ErrorPrintf.
func ErrorPrintln ¶
func ErrorPrintln(args ...interface{})
ErrorPrintln is a convenience function equivalent to Default.ErrorPrintln.
func InfoPrintf ¶
func InfoPrintf(format string, args ...interface{})
InfoPrintf is a convenience function equivalent to Default.InfoPrintf.
func InfoPrintln ¶
func InfoPrintln(args ...interface{})
InfoPrintln is a convenience function equivalent to Default.InfoPrintln.
func WarningPrintf ¶
func WarningPrintf(format string, args ...interface{})
WarningPrintf is a convenience function equivalent to Default.WarningPrintf.
func WarningPrintln ¶
func WarningPrintln(args ...interface{})
WarningPrintln is a convenience function equivalent to Default.WarningPrintln.
Types ¶
type Config ¶
type Config struct {
// Name will be used in the prefix of each log line.
Name string
// CriticalWriter will accept Critical level log output. If set to nil, the
// default os.Stderr will be used. To discard all Critical level output,
// set to an instance of brimio.NullIO.
CriticalWriter io.Writer
// ErrorWriter will accept Error level log output. If set to nil, the
// default os.Stderr will be used. To discard all Error level output, set
// to an instance of brimio.NullIO.
ErrorWriter io.Writer
// WarningWriter will accept Warning level log output. If set to nil, the
// default os.Stderr will be used. To discard all Warning level output, set
// to an instance of brimio.NullIO.
WarningWriter io.Writer
// InfoWriter will accept Info level log output. If set to nil, the default
// os.Stdout will be used. To discard all Info level output, set to
// an instance of brimio.NullIO.
InfoWriter io.Writer
// DebugWriter will accept Debug level log output. If set to nil, the
// default is to discard all Debug level output.
DebugWriter io.Writer
}
Config is used when creating a new Flog instance.
type Flog ¶
type Flog interface {
// CriticalPrintf logs the result of fmt.Sprintf(format, args).
CriticalPrintf(format string, args ...interface{})
// CriticalPrintln logs the result of fmt.Sprintln(args).
CriticalPrintln(args ...interface{})
// ErrorPrintf logs the result of fmt.Sprintf(format, args).
ErrorPrintf(format string, args ...interface{})
// ErrorPrintln logs the result of fmt.Sprintln(args).
ErrorPrintln(args ...interface{})
// WarningPrintf logs the result of fmt.Sprintf(format, args).
WarningPrintf(format string, args ...interface{})
// WarningPrintln logs the result of fmt.Sprintln(args).
WarningPrintln(args ...interface{})
// InfoPrintf logs the result of fmt.Sprintf(format, args).
InfoPrintf(format string, args ...interface{})
// InfoPrintln logs the result of fmt.Sprintln(args).
InfoPrintln(args ...interface{})
// DebugPrintf logs the result of fmt.Sprintf(format, args).
DebugPrintf(format string, args ...interface{})
// DebugPrintln logs the result of fmt.Sprintln(args).
DebugPrintln(args ...interface{})
// Sub creates a new Flog instance based on this one, possibly with
// overrides from the given Config. If Config.Name is set, it will be
// appended to the original Flog instance's name.
Sub(c *Config) Flog
}
Flog provides a logging facility with the usual syslog-style levels of Critical, Error, Warning, Info, and Debug.
type Logger ¶
type Logger interface {
// Fatal is equivalent to Print() followed by a call to os.Exit(1).
Fatal(args ...interface{})
// Fatalf is equivalent to Printf() followed by a call to os.Exit(1).
Fatalf(format string, args ...interface{})
// Fatalln is equivalent to Println() followed by a call to os.Exit(1).
Fatalln(args ...interface{})
// Print calls Output to print to the standard logger. Arguments are
// handled in the manner of fmt.Print.
Print(args ...interface{})
// Printf calls Output to print to the standard logger. Arguments are
// handled in the manner of fmt.Printf.
Printf(format string, args ...interface{})
// Println calls Output to print to the standard logger. Arguments are
// handled in the manner of fmt.Println.
Println(args ...interface{})
}
Logger is an interface to match the most common calls to the standard library's log.Logger.
func CriticalLogger ¶
CriticalLogger returns a Logger instance that will send its output to the Critical level of the Flog given.
func DebugLogger ¶
DebugLogger returns a Logger instance that will send its output to the Debug level of the Flog given.
func ErrorLogger ¶
ErrorLogger returns a Logger instance that will send its output to the Error level of the Flog given.
func InfoLogger ¶
InfoLogger returns a Logger instance that will send its output to the Info level of the Flog given.
func WarningLogger ¶
WarningLogger returns a Logger instance that will send its output to the Warning level of the Flog given.