lumber: github.com/jcelliott/lumber Index | Files

package lumber

import "github.com/jcelliott/lumber"

Package lumber implements a simple logger that supports log levels and rotation.

Index

Package Files

consolelog.go filelog.go lumber.go multilog.go

Constants

const (
    // mode constants
    APPEND = iota
    TRUNC
    BACKUP
    ROTATE
)
const (
    TRACE = iota
    DEBUG
    INFO
    WARN
    ERROR
    FATAL

    TIMEFORMAT = "2006-01-02 15:04:05"
)
const (
    BUFSIZE = 100
)

func Close Uses

func Close()

Close the default logger

func Debug Uses

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

func Error Uses

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

func Fatal Uses

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

Logging functions

func GetLevel Uses

func GetLevel() int

func Info Uses

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

func IsDebug Uses

func IsDebug() bool

func IsError Uses

func IsError() bool

func IsFatal Uses

func IsFatal() bool

func IsInfo Uses

func IsInfo() bool

func IsTrace Uses

func IsTrace() bool

func IsWarn Uses

func IsWarn() bool

func Level Uses

func Level(o int)

Sets the output level for the default logger

func LvlInt Uses

func LvlInt(s string) int

Returns the int value of the level

func LvlStr Uses

func LvlStr(l int) string

Returns the string representation of the level

func Prefix Uses

func Prefix(p string)

Prefix sets a prefix for the default logger

func Print Uses

func Print(lvl int, v ...interface{})

func Printf Uses

func Printf(lvl int, format string, v ...interface{})

func SetLogger Uses

func SetLogger(l Logger)

SetLogger sets a new default logger

func TimeFormat Uses

func TimeFormat(f string)

Sets the time format for the default logger

func Trace Uses

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

func Warn Uses

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

type ConsoleLogger Uses

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

func NewBasicLogger Uses

func NewBasicLogger(f io.WriteCloser, level int) *ConsoleLogger

func NewConsoleLogger Uses

func NewConsoleLogger(o int) *ConsoleLogger

Create a new console logger with output level o, and an empty prefix

func (*ConsoleLogger) Close Uses

func (l *ConsoleLogger) Close()

Close the logger

func (*ConsoleLogger) Debug Uses

func (l *ConsoleLogger) Debug(format string, v ...interface{})

func (*ConsoleLogger) Error Uses

func (l *ConsoleLogger) Error(format string, v ...interface{})

func (*ConsoleLogger) Fatal Uses

func (l *ConsoleLogger) Fatal(format string, v ...interface{})

Logging functions

func (*ConsoleLogger) GetLevel Uses

func (l *ConsoleLogger) GetLevel() int

func (*ConsoleLogger) Info Uses

func (l *ConsoleLogger) Info(format string, v ...interface{})

func (*ConsoleLogger) IsDebug Uses

func (l *ConsoleLogger) IsDebug() bool

func (*ConsoleLogger) IsError Uses

func (l *ConsoleLogger) IsError() bool

func (*ConsoleLogger) IsFatal Uses

func (l *ConsoleLogger) IsFatal() bool

func (*ConsoleLogger) IsInfo Uses

func (l *ConsoleLogger) IsInfo() bool

func (*ConsoleLogger) IsTrace Uses

func (l *ConsoleLogger) IsTrace() bool

func (*ConsoleLogger) IsWarn Uses

func (l *ConsoleLogger) IsWarn() bool

func (*ConsoleLogger) Level Uses

func (l *ConsoleLogger) Level(o int)

Sets the output level for this logger

func (*ConsoleLogger) Prefix Uses

func (l *ConsoleLogger) Prefix(p string)

Sets the prefix for this logger

func (*ConsoleLogger) Print Uses

func (l *ConsoleLogger) Print(lvl int, v ...interface{})

func (*ConsoleLogger) Printf Uses

func (l *ConsoleLogger) Printf(lvl int, format string, v ...interface{})

func (*ConsoleLogger) SetLevels Uses

func (l *ConsoleLogger) SetLevels(lvls []string)

Sets the available levels for this logger

func (*ConsoleLogger) TimeFormat Uses

func (l *ConsoleLogger) TimeFormat(f string)

Sets the time format for this logger

func (*ConsoleLogger) Trace Uses

func (l *ConsoleLogger) Trace(format string, v ...interface{})

func (*ConsoleLogger) Warn Uses

func (l *ConsoleLogger) Warn(format string, v ...interface{})

type FileLogger Uses

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

func NewAppendLogger Uses

func NewAppendLogger(f string) (*FileLogger, error)

Convenience function to create a new append-only logger

func NewBackupLogger Uses

func NewBackupLogger(f string, maxBackup int) (*FileLogger, error)

Convenience function to create a new backup logger

func NewBasicFileLogger Uses

func NewBasicFileLogger(f *os.File, level int) (l *FileLogger)

func NewFileLogger Uses

func NewFileLogger(f string, o, mode, maxLines, maxRotate, bufsize int) (*FileLogger, error)

Creates a new FileLogger with filename f, output level o, and an empty prefix. Modes are described in the documentation; maxLines and maxRotate are only significant for some modes.

func NewRotateLogger Uses

func NewRotateLogger(f string, maxLines, maxRotate int) (*FileLogger, error)

Convenience function to create a new rotating logger

func NewTruncateLogger Uses

func NewTruncateLogger(f string) (*FileLogger, error)

Convenience function to create a new truncating logger

func (*FileLogger) Close Uses

func (l *FileLogger) Close()

Flush the messages in the queue and shut down the logger.

func (*FileLogger) Debug Uses

func (l *FileLogger) Debug(format string, v ...interface{})

func (*FileLogger) Error Uses

func (l *FileLogger) Error(format string, v ...interface{})

func (*FileLogger) Fatal Uses

func (l *FileLogger) Fatal(format string, v ...interface{})

Logging functions

func (*FileLogger) GetLevel Uses

func (l *FileLogger) GetLevel() int

func (*FileLogger) Info Uses

func (l *FileLogger) Info(format string, v ...interface{})

func (*FileLogger) IsDebug Uses

func (l *FileLogger) IsDebug() bool

func (*FileLogger) IsError Uses

func (l *FileLogger) IsError() bool

func (*FileLogger) IsFatal Uses

func (l *FileLogger) IsFatal() bool

func (*FileLogger) IsInfo Uses

func (l *FileLogger) IsInfo() bool

func (*FileLogger) IsTrace Uses

func (l *FileLogger) IsTrace() bool

func (*FileLogger) IsWarn Uses

func (l *FileLogger) IsWarn() bool

func (*FileLogger) Level Uses

func (l *FileLogger) Level(o int)

Sets the output level for this logger

func (*FileLogger) Prefix Uses

func (l *FileLogger) Prefix(p string)

Sets the prefix for this logger

func (*FileLogger) Print Uses

func (l *FileLogger) Print(lvl int, v ...interface{})

func (*FileLogger) Printf Uses

func (l *FileLogger) Printf(lvl int, format string, v ...interface{})

func (*FileLogger) SetLevels Uses

func (l *FileLogger) SetLevels(lvls []string)

Sets the available levels for this logger TODO: append a *LOG* level

func (*FileLogger) TimeFormat Uses

func (l *FileLogger) TimeFormat(f string)

Sets the time format for this logger

func (*FileLogger) Trace Uses

func (l *FileLogger) Trace(format string, v ...interface{})

func (*FileLogger) Warn Uses

func (l *FileLogger) Warn(format string, v ...interface{})

type Logger Uses

type Logger interface {
    Fatal(string, ...interface{})
    Error(string, ...interface{})
    Warn(string, ...interface{})
    Info(string, ...interface{})
    Debug(string, ...interface{})
    Trace(string, ...interface{})

    IsFatal() bool
    IsError() bool
    IsWarn() bool
    IsInfo() bool
    IsDebug() bool
    IsTrace() bool
    GetLevel() int

    Print(int, ...interface{})
    Printf(int, string, ...interface{})
    Level(int)
    Prefix(string)
    TimeFormat(string)
    Close()
    // contains filtered or unexported methods
}

type Message Uses

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

type MultiLogger Uses

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

func NewMultiLogger Uses

func NewMultiLogger() (l *MultiLogger)

func (*MultiLogger) AddLoggers Uses

func (p *MultiLogger) AddLoggers(newLogs ...Logger)

func (*MultiLogger) ClearLoggers Uses

func (p *MultiLogger) ClearLoggers()

func (*MultiLogger) Close Uses

func (p *MultiLogger) Close()

func (*MultiLogger) Debug Uses

func (p *MultiLogger) Debug(s string, v ...interface{})

func (*MultiLogger) Error Uses

func (p *MultiLogger) Error(s string, v ...interface{})

func (*MultiLogger) Fatal Uses

func (p *MultiLogger) Fatal(s string, v ...interface{})

All of these implement the Logger interface and distribute calls to it over all of the member Logger objects.

func (*MultiLogger) GetLevel Uses

func (p *MultiLogger) GetLevel() int

func (*MultiLogger) Info Uses

func (p *MultiLogger) Info(s string, v ...interface{})

func (*MultiLogger) IsDebug Uses

func (p *MultiLogger) IsDebug() bool

func (*MultiLogger) IsError Uses

func (p *MultiLogger) IsError() bool

func (*MultiLogger) IsFatal Uses

func (p *MultiLogger) IsFatal() bool

func (*MultiLogger) IsInfo Uses

func (p *MultiLogger) IsInfo() bool

func (*MultiLogger) IsTrace Uses

func (p *MultiLogger) IsTrace() bool

func (*MultiLogger) IsWarn Uses

func (p *MultiLogger) IsWarn() bool

func (*MultiLogger) Level Uses

func (p *MultiLogger) Level(i int)

func (*MultiLogger) Prefix Uses

func (p *MultiLogger) Prefix(s string)

func (*MultiLogger) Print Uses

func (p *MultiLogger) Print(lvl int, v ...interface{})

func (*MultiLogger) Printf Uses

func (p *MultiLogger) Printf(lvl int, format string, v ...interface{})

func (*MultiLogger) TimeFormat Uses

func (p *MultiLogger) TimeFormat(s string)

func (*MultiLogger) Trace Uses

func (p *MultiLogger) Trace(s string, v ...interface{})

func (*MultiLogger) Warn Uses

func (p *MultiLogger) Warn(s string, v ...interface{})

Package lumber imports 9 packages (graph) and is imported by 118 packages. Updated 2016-08-02. Refresh now. Tools for package owners.