Skip to content

ewwwwwqm/logdump

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Package for multi-level logging

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages