bosun.org: bosun.org/slog Index | Files

package slog

import "bosun.org/slog"

Package slog provides a cross-platform logging interface. It is designed to provide a universal logging interface on any operating system. It defaults to using the log package of the standard library, but can easily be used with other logging backends. Thus, we can use syslog on unicies and the event log on windows.

Index

Package Files

slog.go slog_unix.go

Variables

var (
    // LogLineNumber prints the file and line number of the caller.
    LogLineNumber = true
)

func Error Uses

func Error(v ...interface{})

Error logs an error message.

func Errorf Uses

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

Errorf logs an error message.

func Errorln Uses

func Errorln(v ...interface{})

Errorln logs an error message.

func Fatal Uses

func Fatal(v ...interface{})

Fatal logs a fatal message and calls os.Exit(1).

func Fatalf Uses

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

Fatalf logs a fatal message and calls os.Exit(1).

func Fatalln Uses

func Fatalln(v ...interface{})

Fatalln logs a fatal message and calls os.Exit(1).

func Info Uses

func Info(v ...interface{})

Info logs an info message.

func Infof Uses

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

Infof logs an info message.

func Infoln Uses

func Infoln(v ...interface{})

Infoln logs an info message.

func PanicAsFatal Uses

func PanicAsFatal()

Add defer slog.PanicAsFatal() to the top of a goroutine to recover panics and log them using slog.Fatal

func Set Uses

func Set(l Logger)

Set configures l to be the default logger for slog.

func SetSyslog Uses

func SetSyslog(tag string) error

SetSyslog configures slog to use the system syslog daemon.

func Warning Uses

func Warning(v ...interface{})

Warning logs a warning message.

func Warningf Uses

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

Warningf logs a warning message.

func Warningln Uses

func Warningln(v ...interface{})

Warningln logs a warning message.

func Wrap Uses

func Wrap(err error) error

Helper to wrap an error with relevant line information. Wrap an error when it enters "our" code before passing it up the stack. This will help narrow down the source of the error.

type Logger Uses

type Logger interface {
    Error(v string)
    Info(v string)
    Warning(v string)
    Fatal(v string)
}

Logger is the slog logging interface.

type StdLog Uses

type StdLog struct {
    Log *log.Logger
}

StdLog logs to a log.Logger.

func (*StdLog) Error Uses

func (s *StdLog) Error(v string)

Error logs an error message.

func (*StdLog) Fatal Uses

func (s *StdLog) Fatal(v string)

Fatal logs a fatal message and calls os.Exit(1).

func (*StdLog) Info Uses

func (s *StdLog) Info(v string)

Info logs an info message.

func (*StdLog) Warning Uses

func (s *StdLog) Warning(v string)

Warning logs a warning message.

type Syslog Uses

type Syslog struct {
    W *syslog.Writer
}

Syslog logs to syslog.

func (*Syslog) Error Uses

func (s *Syslog) Error(v string)

Error logs an error message.

func (*Syslog) Fatal Uses

func (s *Syslog) Fatal(v string)

Fatal logs a fatal message and calls os.Exit(1).

func (*Syslog) Info Uses

func (s *Syslog) Info(v string)

Info logs an info message.

func (*Syslog) Warning Uses

func (s *Syslog) Warning(v string)

Warning logs a warning message.

Package slog imports 8 packages (graph) and is imported by 26 packages. Updated 2017-01-24. Refresh now. Tools for package owners.