maulogger

package module
v2.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2019 License: GPL-3.0 Imports: 3 Imported by: 33

README

maulogger

A logger in Go.

Docs: godoc.org/maunium.net/go/maulogger

Go get: go get maunium.net/go/maulogger

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// LevelDebug is the level for debug messages.
	LevelDebug = Level{Name: "DEBUG", Color: -1, Severity: 0}
	// LevelInfo is the level for basic log messages.
	LevelInfo = Level{Name: "INFO", Color: 36, Severity: 10}
	// LevelWarn is the level saying that something went wrong, but the program will continue operating mostly normally.
	LevelWarn = Level{Name: "WARN", Color: 33, Severity: 50}
	// LevelError is the level saying that something went wrong and the program may not operate as expected, but will still continue.
	LevelError = Level{Name: "ERROR", Color: 31, Severity: 100}
	// LevelFatal is the level saying that something went wrong and the program will not operate normally.
	LevelFatal = Level{Name: "FATAL", Color: 35, Severity: 9001}
)
View Source
var DefaultLogger = Create().(*BasicLogger)

DefaultLogger ...

Functions

func Close

func Close() error

Close formats the given parts with fmt.Sprint and logs the result with the Close level

func Debug

func Debug(parts ...interface{})

Debug formats the given parts with fmt.Sprint and logs the result with the Debug level

func Debugf

func Debugf(message string, args ...interface{})

Debugf formats the given message and args with fmt.Sprintf and logs the result with the Debug level

func Debugfln added in v2.1.0

func Debugfln(message string, args ...interface{})

Debugfln formats the given message and args with fmt.Sprintf, appends a newline and logs the result with the Debug level

func Debugln

func Debugln(parts ...interface{})

Debugln formats the given parts with fmt.Sprintln and logs the result with the Debug level

func Error

func Error(parts ...interface{})

Error formats the given parts with fmt.Sprint and logs the result with the Error level

func Errorf

func Errorf(message string, args ...interface{})

Errorf formats the given message and args with fmt.Sprintf and logs the result with the Error level

func Errorfln added in v2.1.0

func Errorfln(message string, args ...interface{})

Errorfln formats the given message and args with fmt.Sprintf, appends a newline and logs the result with the Error level

func Errorln

func Errorln(parts ...interface{})

Errorln formats the given parts with fmt.Sprintln and logs the result with the Error level

func Fatal

func Fatal(parts ...interface{})

Fatal formats the given parts with fmt.Sprint and logs the result with the Fatal level

func Fatalf

func Fatalf(message string, args ...interface{})

Fatalf formats the given message and args with fmt.Sprintf and logs the result with the Fatal level

func Fatalfln added in v2.1.0

func Fatalfln(message string, args ...interface{})

Fatalfln formats the given message and args with fmt.Sprintf, appends a newline and logs the result with the Fatal level

func Fatalln

func Fatalln(parts ...interface{})

Fatalln formats the given parts with fmt.Sprintln and logs the result with the Fatal level

func Info

func Info(parts ...interface{})

Info formats the given parts with fmt.Sprint and logs the result with the Info level

func Infof

func Infof(message string, args ...interface{})

Infof formats the given message and args with fmt.Sprintf and logs the result with the Info level

func Infofln added in v2.1.0

func Infofln(message string, args ...interface{})

Infofln formats the given message and args with fmt.Sprintf, appends a newline and logs the result with the Info level

func Infoln

func Infoln(parts ...interface{})

Infoln formats the given parts with fmt.Sprintln and logs the result with the Info level

func Log

func Log(level Level, parts ...interface{})

Log formats the given parts with fmt.Sprint and logs the result with the given level

func Logf

func Logf(level Level, message string, args ...interface{})

Logf formats the given message and args with fmt.Sprintf and logs the result with the given level

func Logfln

func Logfln(level Level, message string, args ...interface{})

Logfln formats the given message and args with fmt.Sprintf, appends a newline and logs the result with the given level

func Logln

func Logln(level Level, parts ...interface{})

Logln formats the given parts with fmt.Sprintln and logs the result with the given level

func OpenFile

func OpenFile() error

OpenFile formats the given parts with fmt.Sprint and logs the result with the OpenFile level

func Raw

func Raw(level Level, module, message string)

Raw formats the given parts with fmt.Sprint and logs the result with the Raw level

func SetWriter

func SetWriter(w *os.File)

SetWriter formats the given parts with fmt.Sprint and logs the result with the SetWriter level

func Warn

func Warn(parts ...interface{})

Warn formats the given parts with fmt.Sprint and logs the result with the Warn level

func Warnf

func Warnf(message string, args ...interface{})

Warnf formats the given message and args with fmt.Sprintf and logs the result with the Warn level

func Warnfln added in v2.1.0

func Warnfln(message string, args ...interface{})

Warnfln formats the given message and args with fmt.Sprintf, appends a newline and logs the result with the Warn level

func Warnln

func Warnln(parts ...interface{})

Warnln formats the given parts with fmt.Sprintln and logs the result with the Warn level

Types

type BasicLogger

type BasicLogger struct {
	PrintLevel         int
	FlushLineThreshold int
	FileTimeFormat     string
	FileFormat         LoggerFileFormat
	TimeFormat         string
	FileMode           os.FileMode
	DefaultSub         Logger
	// contains filtered or unexported fields
}

func (*BasicLogger) Close

func (log *BasicLogger) Close() error

Close formats the given parts with fmt.Sprint and logs the result with the Close level

func (*BasicLogger) Debug

func (log *BasicLogger) Debug(parts ...interface{})

Debug formats the given parts with fmt.Sprint and logs the result with the Debug level

func (*BasicLogger) Debugf

func (log *BasicLogger) Debugf(message string, args ...interface{})

Debugf formats the given message and args with fmt.Sprintf and logs the result with the Debug level

func (*BasicLogger) Debugfln

func (log *BasicLogger) Debugfln(message string, args ...interface{})

Debugfln formats the given message and args with fmt.Sprintf, appends a newline and logs the result with the Debug level

func (*BasicLogger) Debugln

func (log *BasicLogger) Debugln(parts ...interface{})

Debugln formats the given parts with fmt.Sprintln and logs the result with the Debug level

func (*BasicLogger) Error

func (log *BasicLogger) Error(parts ...interface{})

Error formats the given parts with fmt.Sprint and logs the result with the Error level

func (*BasicLogger) Errorf

func (log *BasicLogger) Errorf(message string, args ...interface{})

Errorf formats the given message and args with fmt.Sprintf and logs the result with the Error level

func (*BasicLogger) Errorfln

func (log *BasicLogger) Errorfln(message string, args ...interface{})

Errorfln formats the given message and args with fmt.Sprintf, appends a newline and logs the result with the Error level

func (*BasicLogger) Errorln

func (log *BasicLogger) Errorln(parts ...interface{})

Errorln formats the given parts with fmt.Sprintln and logs the result with the Error level

func (*BasicLogger) Fatal

func (log *BasicLogger) Fatal(parts ...interface{})

Fatal formats the given parts with fmt.Sprint and logs the result with the Fatal level

func (*BasicLogger) Fatalf

func (log *BasicLogger) Fatalf(message string, args ...interface{})

Fatalf formats the given message and args with fmt.Sprintf and logs the result with the Fatal level

func (*BasicLogger) Fatalfln

func (log *BasicLogger) Fatalfln(message string, args ...interface{})

Fatalfln formats the given message and args with fmt.Sprintf, appends a newline and logs the result with the Fatal level

func (*BasicLogger) Fatalln

func (log *BasicLogger) Fatalln(parts ...interface{})

Fatalln formats the given parts with fmt.Sprintln and logs the result with the Fatal level

func (*BasicLogger) GetParent

func (log *BasicLogger) GetParent() Logger

func (*BasicLogger) Info

func (log *BasicLogger) Info(parts ...interface{})

Info formats the given parts with fmt.Sprint and logs the result with the Info level

func (*BasicLogger) Infof

func (log *BasicLogger) Infof(message string, args ...interface{})

Infof formats the given message and args with fmt.Sprintf and logs the result with the Info level

func (*BasicLogger) Infofln

func (log *BasicLogger) Infofln(message string, args ...interface{})

Infofln formats the given message and args with fmt.Sprintf, appends a newline and logs the result with the Info level

func (*BasicLogger) Infoln

func (log *BasicLogger) Infoln(parts ...interface{})

Infoln formats the given parts with fmt.Sprintln and logs the result with the Info level

func (*BasicLogger) Log

func (log *BasicLogger) Log(level Level, parts ...interface{})

Log formats the given parts with fmt.Sprint and logs the result with the given level

func (*BasicLogger) Logf

func (log *BasicLogger) Logf(level Level, message string, args ...interface{})

Logf formats the given message and args with fmt.Sprintf and logs the result with the given level

func (*BasicLogger) Logfln

func (log *BasicLogger) Logfln(level Level, message string, args ...interface{})

Logfln formats the given message and args with fmt.Sprintf, appends a newline and logs the result with the given level

func (*BasicLogger) Logln

func (log *BasicLogger) Logln(level Level, parts ...interface{})

Logln formats the given parts with fmt.Sprintln and logs the result with the given level

func (*BasicLogger) OpenFile

func (log *BasicLogger) OpenFile() error

OpenFile formats the given parts with fmt.Sprint and logs the result with the OpenFile level

func (*BasicLogger) Raw

func (log *BasicLogger) Raw(level Level, module, message string)

Raw formats the given parts with fmt.Sprint and logs the result with the Raw level

func (*BasicLogger) SetWriter

func (log *BasicLogger) SetWriter(w *os.File)

SetWriter formats the given parts with fmt.Sprint and logs the result with the SetWriter level

func (*BasicLogger) Sub

func (log *BasicLogger) Sub(module string) Logger

Sub creates a Sublogger

func (*BasicLogger) Warn

func (log *BasicLogger) Warn(parts ...interface{})

Warn formats the given parts with fmt.Sprint and logs the result with the Warn level

func (*BasicLogger) Warnf

func (log *BasicLogger) Warnf(message string, args ...interface{})

Warnf formats the given message and args with fmt.Sprintf and logs the result with the Warn level

func (*BasicLogger) Warnfln

func (log *BasicLogger) Warnfln(message string, args ...interface{})

Warnfln formats the given message and args with fmt.Sprintf, appends a newline and logs the result with the Warn level

func (*BasicLogger) Warnln

func (log *BasicLogger) Warnln(parts ...interface{})

Warnln formats the given parts with fmt.Sprintln and logs the result with the Warn level

func (*BasicLogger) WithDefaultLevel added in v2.1.1

func (log *BasicLogger) WithDefaultLevel(lvl Level) Logger

WithDefaultLevel creates a Sublogger with the same Module but different DefaultLevel

func (*BasicLogger) Write

func (log *BasicLogger) Write(p []byte) (n int, err error)

Write formats the given parts with fmt.Sprint and logs the result with the Write level

type Level

type Level struct {
	Name            string
	Severity, Color int
}

Level is the severity level of a log entry.

func (Level) GetColor

func (lvl Level) GetColor() string

GetColor gets the ANSI escape color code for the log level.

func (Level) GetReset

func (lvl Level) GetReset() string

GetReset gets the ANSI escape reset code.

type Logger

type Logger interface {
	Sub(module string) Logger
	WithDefaultLevel(level Level) Logger
	GetParent() Logger

	Write(p []byte) (n int, err error)

	Log(level Level, parts ...interface{})
	Logln(level Level, parts ...interface{})
	Logf(level Level, message string, args ...interface{})
	Logfln(level Level, message string, args ...interface{})

	Debug(parts ...interface{})
	Debugln(parts ...interface{})
	Debugf(message string, args ...interface{})
	Debugfln(message string, args ...interface{})
	Info(parts ...interface{})
	Infoln(parts ...interface{})
	Infof(message string, args ...interface{})
	Infofln(message string, args ...interface{})
	Warn(parts ...interface{})
	Warnln(parts ...interface{})
	Warnf(message string, args ...interface{})
	Warnfln(message string, args ...interface{})
	Error(parts ...interface{})
	Errorln(parts ...interface{})
	Errorf(message string, args ...interface{})
	Errorfln(message string, args ...interface{})
	Fatal(parts ...interface{})
	Fatalln(parts ...interface{})
	Fatalf(message string, args ...interface{})
	Fatalfln(message string, args ...interface{})
}

Logger contains advanced logging functions and also implements io.Writer

func Create

func Create() Logger

Create a Logger

func Sub

func Sub(module string) Logger

Sub creates a Sublogger

type LoggerFileFormat

type LoggerFileFormat func(now string, i int) string

LoggerFileFormat ...

type Sublogger

type Sublogger struct {
	Module       string
	DefaultLevel Level
	// contains filtered or unexported fields
}

func (*Sublogger) Debug

func (log *Sublogger) Debug(parts ...interface{})

Debug formats the given parts with fmt.Sprint and logs the result with the Debug level

func (*Sublogger) Debugf

func (log *Sublogger) Debugf(message string, args ...interface{})

Debugf formats the given message and args with fmt.Sprintf and logs the result with the Debug level

func (*Sublogger) Debugfln

func (log *Sublogger) Debugfln(message string, args ...interface{})

Debugfln formats the given message and args with fmt.Sprintf, appends a newline and logs the result with the Debug level

func (*Sublogger) Debugln

func (log *Sublogger) Debugln(parts ...interface{})

Debugln formats the given parts with fmt.Sprintln and logs the result with the Debug level

func (*Sublogger) Error

func (log *Sublogger) Error(parts ...interface{})

Error formats the given parts with fmt.Sprint and logs the result with the Error level

func (*Sublogger) Errorf

func (log *Sublogger) Errorf(message string, args ...interface{})

Errorf formats the given message and args with fmt.Sprintf and logs the result with the Error level

func (*Sublogger) Errorfln

func (log *Sublogger) Errorfln(message string, args ...interface{})

Errorfln formats the given message and args with fmt.Sprintf, appends a newline and logs the result with the Error level

func (*Sublogger) Errorln

func (log *Sublogger) Errorln(parts ...interface{})

Errorln formats the given parts with fmt.Sprintln and logs the result with the Error level

func (*Sublogger) Fatal

func (log *Sublogger) Fatal(parts ...interface{})

Fatal formats the given parts with fmt.Sprint and logs the result with the Fatal level

func (*Sublogger) Fatalf

func (log *Sublogger) Fatalf(message string, args ...interface{})

Fatalf formats the given message and args with fmt.Sprintf and logs the result with the Fatal level

func (*Sublogger) Fatalfln

func (log *Sublogger) Fatalfln(message string, args ...interface{})

Fatalfln formats the given message and args with fmt.Sprintf, appends a newline and logs the result with the Fatal level

func (*Sublogger) Fatalln

func (log *Sublogger) Fatalln(parts ...interface{})

Fatalln formats the given parts with fmt.Sprintln and logs the result with the Fatal level

func (*Sublogger) GetParent

func (log *Sublogger) GetParent() Logger

func (*Sublogger) Info

func (log *Sublogger) Info(parts ...interface{})

Info formats the given parts with fmt.Sprint and logs the result with the Info level

func (*Sublogger) Infof

func (log *Sublogger) Infof(message string, args ...interface{})

Infof formats the given message and args with fmt.Sprintf and logs the result with the Info level

func (*Sublogger) Infofln

func (log *Sublogger) Infofln(message string, args ...interface{})

Infofln formats the given message and args with fmt.Sprintf, appends a newline and logs the result with the Info level

func (*Sublogger) Infoln

func (log *Sublogger) Infoln(parts ...interface{})

Infoln formats the given parts with fmt.Sprintln and logs the result with the Info level

func (*Sublogger) Log

func (log *Sublogger) Log(level Level, parts ...interface{})

Log formats the given parts with fmt.Sprint and logs the result with the given level

func (*Sublogger) Logf

func (log *Sublogger) Logf(level Level, message string, args ...interface{})

Logf formats the given message and args with fmt.Sprintf and logs the result with the given level

func (*Sublogger) Logfln

func (log *Sublogger) Logfln(level Level, message string, args ...interface{})

Logfln formats the given message and args with fmt.Sprintf, appends a newline and logs the result with the given level

func (*Sublogger) Logln

func (log *Sublogger) Logln(level Level, parts ...interface{})

Logln formats the given parts with fmt.Sprintln and logs the result with the given level

func (*Sublogger) SetDefaultLevel

func (log *Sublogger) SetDefaultLevel(lvl Level)

SetDefaultLevel changes the default logging level of this Sublogger

func (*Sublogger) SetModule

func (log *Sublogger) SetModule(mod string)

SetModule changes the module name of this Sublogger

func (*Sublogger) SetParent

func (log *Sublogger) SetParent(parent *BasicLogger)

SetParent changes the parent of this Sublogger

func (*Sublogger) Sub

func (log *Sublogger) Sub(module string) Logger

Sub creates a Sublogger

func (*Sublogger) Warn

func (log *Sublogger) Warn(parts ...interface{})

Warn formats the given parts with fmt.Sprint and logs the result with the Warn level

func (*Sublogger) Warnf

func (log *Sublogger) Warnf(message string, args ...interface{})

Warnf formats the given message and args with fmt.Sprintf and logs the result with the Warn level

func (*Sublogger) Warnfln

func (log *Sublogger) Warnfln(message string, args ...interface{})

Warnfln formats the given message and args with fmt.Sprintf, appends a newline and logs the result with the Warn level

func (*Sublogger) Warnln

func (log *Sublogger) Warnln(parts ...interface{})

Warnln formats the given parts with fmt.Sprintln and logs the result with the Warn level

func (*Sublogger) WithDefaultLevel added in v2.1.1

func (log *Sublogger) WithDefaultLevel(lvl Level) Logger

WithDefaultLevel creates a Sublogger with the same Module but different DefaultLevel

func (*Sublogger) Write

func (log *Sublogger) Write(p []byte) (n int, err error)

Write ...

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL