Usage - pd93/plog GitHub Wiki
-
Import the package (aliasing to
log
is recommended)import ( log "gopkg.in/pd93/plog.v0" )
-
Create a new file writer
logFile, err := log.NewBufWriter("log.json", 100) if err != nil { return err } defer logFile.Close()
-
Set up your loggers
// Standard logger log.AddLogger("std", log.NewLogger()) // JSON file logger log.AddLogger("json", log.NewJSONFileLogger(logFile))
-
Log things!
// Write to all loggers log.Info("Starting process") log.Debug(vars, to, debug) log.Debugf("%.2f", num) // Write to a specific logger log.GetLogger("std").Info("Special log that only prints to stdout")