• Stars
    star
    11
  • Rank 1,639,057 (Top 34 %)
  • Language
    Go
  • Created over 7 years ago
  • Updated about 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Package for multi-level logging

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