📚 logdump - Awesome Go Library for Logging
Package for multi-level logging.
🏷️ Logging
📂 Libraries for generating and working with log files.
⭐ 11 stars
Detailed Description of logdump
Logdump
Package for writing logs to multiple files
Usage
$ go get github.com/ewwwwwqm/logdump
Example
main.go
package main
import (
"log"
"github.com/ewwwwwqm/logdump"
)
func main() {
// create message zones and assign files for output
newLog := map[string]interface{}{
"error": "error.log",
"warning": "warning.log",
"notice": "notice.log",
}
// init logger
logdump.Init(newLog)
// for ex. dump error
logdump.Write("error", "something had an error")
// default output
log.Println("Standard output to os.Stderr")
// few more errors
logdump.Write("notice", "some notice")
logdump.Write("error", "another error")
logdump.Write("warning", "fancy warning")
// wrong message zone, output to os.Stderr
logdump.Write("wrong_zone", "fail")
}
Before running:
Run the app:
$ go run main.go
Files were created.
Output
os.Stderr:
2017/01/13 17:45:48 Standard output to os.Stderr
2017/01/13 17:45:48 Type wrong_zone was not assigned for log output
error.log
2017/01/13 17:45:48 Start error logging
2017/01/13 17:45:48 something had an error
2017/01/13 17:45:48 another error
warning.log
2017/01/13 17:45:48 Start warning logging
2017/01/13 17:45:48 fancy warning
notice.log
2017/01/13 17:45:48 Start notice logging
2017/01/13 17:45:48 some notice