Documentation ¶
Overview ¶
Package ledger provides a threadsafe, minimalist logger on top of native Go logging. Adding the ability to write to more than standard out and honor log level thresholds.
Example (Exported) ¶
ExampleExported demonstrates the default exported logger
package main import ( "github.com/gomicro/ledger" ) func main() { ledger.Debug("We've got a debug line here") ledger.Info("We've got a info line here") ledger.Warn("We've got a warn line here") ledger.Error("We've got a error line here") ledger.Fatal("We've got a fatal line here") }
Output:
Example (Global) ¶
package main import ( "os" "github.com/gomicro/ledger" ) var ( log *ledger.Ledger ) func init() { log = ledger.New(os.Stdout, ledger.DebugLevel) } func main() { log.Debug("We've got a debug line here") log.Info("We've got a info line here") log.Warn("We've got a warn line here") log.Error("We've got a error line here") log.Fatal("We've got a fatal line here") }
Output:
Index ¶
- func Debug(args ...interface{})
- func Debugf(f string, args ...interface{})
- func EndpointDebug(next http.Handler) http.Handler
- func EndpointInfo(next http.Handler) http.Handler
- func Error(args ...interface{})
- func Errorf(f string, args ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(f string, args ...interface{})
- func Info(args ...interface{})
- func Infof(f string, args ...interface{})
- func Threshold(level Level)
- func Warn(args ...interface{})
- func Warnf(f string, args ...interface{})
- func Writer(writer io.Writer)
- type Ledger
- func (l *Ledger) Debug(args ...interface{})
- func (l *Ledger) Debugf(f string, args ...interface{})
- func (l *Ledger) EndpointDebug(next http.Handler) http.Handler
- func (l *Ledger) EndpointInfo(next http.Handler) http.Handler
- func (l *Ledger) Error(args ...interface{})
- func (l *Ledger) Errorf(f string, args ...interface{})
- func (l *Ledger) Fatal(args ...interface{})
- func (l *Ledger) Fatalf(f string, args ...interface{})
- func (l *Ledger) Info(args ...interface{})
- func (l *Ledger) Infof(f string, args ...interface{})
- func (l *Ledger) Threshold(level Level)
- func (l *Ledger) Warn(args ...interface{})
- func (l *Ledger) Warnf(f string, args ...interface{})
- type Level
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Debugf ¶
func Debugf(f string, args ...interface{})
Debugf writes a string formatted log entry with the debug log level
func EndpointDebug ¶ added in v0.0.4
EndpointDebug wraps the given http handler and logs details of the endpoint at the Debug threshold
func EndpointInfo ¶ added in v0.0.4
EndpointInfo wraps the given http handler and logs details of the endpoint at the Info threshold
func Errorf ¶
func Errorf(f string, args ...interface{})
Errorf writes a string formatted log entry with the error log level
func Fatalf ¶
func Fatalf(f string, args ...interface{})
Fatalf writes a string formatted log entry with the fatal log level
func Infof ¶
func Infof(f string, args ...interface{})
Infof writes a string formatted log entry with the info log level
func Threshold ¶ added in v0.0.2
func Threshold(level Level)
Threshold sets the log level threshold for the exported logger
Types ¶
type Ledger ¶
type Ledger struct {
// contains filtered or unexported fields
}
Ledger represents a logger
func (*Ledger) Debug ¶
func (l *Ledger) Debug(args ...interface{})
Debug writes a log entry with the debug log level
func (*Ledger) EndpointDebug ¶ added in v0.0.4
EndpointDebug wraps the given http handler and logs details of the endpoint at the Debug threshold
func (*Ledger) EndpointInfo ¶ added in v0.0.4
EndpointInfo wraps the given http handler and logs details of the endpoint at the Info threshold
func (*Ledger) Error ¶
func (l *Ledger) Error(args ...interface{})
Error writes a log entry with the error log level
func (*Ledger) Fatal ¶
func (l *Ledger) Fatal(args ...interface{})
Fatal writes a log entry with the fatal log level
func (*Ledger) Info ¶
func (l *Ledger) Info(args ...interface{})
Info writes a log entry with the info log level
func (*Ledger) Threshold ¶ added in v0.0.2
Threshold sets the log level threshold for the defined logger