Skip to content
Package for multi-level logging
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.travis.yml
README.md rank pics readme refresh Apr 2, 2018
logdump.go go fmt da code Apr 2, 2018
logdump_test.go

README.md

Logdump

Godoc Reference Build Status Go Report Card

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:

Before run

Run the app:

$ go run main.go

After run

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
You can’t perform that action at this time.