flog: github.com/gholt/flog Index | Files

package flog

import "github.com/gholt/flog"

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

Package Files

flog.go

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.

func CriticalPrintf Uses

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

CriticalPrintf is a convenience function equivalent to Default.CriticalPrintf.

func CriticalPrintln Uses

func CriticalPrintln(args ...interface{})

CriticalPrintln is a convenience function equivalent to Default.CriticalPrintln.

func DebugPrintf Uses

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

DebugPrintf is a convenience function equivalent to Default.DebugPrintf.

func DebugPrintln Uses

func DebugPrintln(args ...interface{})

DebugPrintln is a convenience function equivalent to Default.DebugPrintln.

func ErrorPrintf Uses

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

ErrorPrintf is a convenience function equivalent to Default.ErrorPrintf.

func ErrorPrintln Uses

func ErrorPrintln(args ...interface{})

ErrorPrintln is a convenience function equivalent to Default.ErrorPrintln.

func InfoPrintf Uses

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

InfoPrintf is a convenience function equivalent to Default.InfoPrintf.

func InfoPrintln Uses

func InfoPrintln(args ...interface{})

InfoPrintln is a convenience function equivalent to Default.InfoPrintln.

func WarningPrintf Uses

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

WarningPrintf is a convenience function equivalent to Default.WarningPrintf.

func WarningPrintln Uses

func WarningPrintln(args ...interface{})

WarningPrintln is a convenience function equivalent to Default.WarningPrintln.

type Config Uses

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 Uses

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.

func New Uses

func New(c *Config) Flog

New returns a new Flog instance based on the Config given.

func Sub Uses

func Sub(c *Config) Flog

Sub is a convenience function equivalent to Default.Sub.

type Logger Uses

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 Uses

func CriticalLogger(f Flog) Logger

CriticalLogger returns a Logger instance that will send its output to the Critical level of the Flog given.

func DebugLogger Uses

func DebugLogger(f Flog) Logger

DebugLogger returns a Logger instance that will send its output to the Debug level of the Flog given.

func ErrorLogger Uses

func ErrorLogger(f Flog) Logger

ErrorLogger returns a Logger instance that will send its output to the Error level of the Flog given.

func InfoLogger Uses

func InfoLogger(f Flog) Logger

InfoLogger returns a Logger instance that will send its output to the Info level of the Flog given.

func WarningLogger Uses

func WarningLogger(f Flog) Logger

WarningLogger returns a Logger instance that will send its output to the Warning level of the Flog given.

Package flog imports 7 packages (graph) and is imported by 2 packages. Updated 2016-11-11. Refresh now. Tools for package owners.