Categorygithub.com/jamesruan/golf
repositorypackage
0.2.0
Repository: https://github.com/jamesruan/golf.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# README

Go LOggering Framework

See documents GoDoc.

Features and TODOs

  • Entry -> Handler... -> Logger architecture where Logger runs in a separate goroutine and allows asynchronous logging.

  • Flexible handlers that can broadcast and forward logging events to logger in different condition.

  • Multi-goroutine safe handlers that can change event route condition online.

  • Support file based output and rotate with lumberjack, response to os.Signal for triggered rotate.

  • Support network output with file based spooling.

  • Console formatter

    • Colorized.
    • Call stack print.
    • Calling position (file:line).
    • Line-bufferred output.

Example

import (
	"github.com/jamesruan/golf"
	"github.com/jamesruan/golf/event"
)

func main() {
	logger := golf.DefaultEntry
	logger.Infof("Hello, World!")

	topic_logger := golf.NewTopicEntry("mytopic", golf.DefaultSink)
	topic_logger.Infof("log with topic")

	field_logger := topic_logger.WithFields(event.Field{
		Name: "field",
		Value: "field_value",
	})

	field_logger.Infof("log with field")
	field_logger.Fatalf("make sure log is flushed")
}