rea
github.com/matejb/reactlog
go get github.com/matejb/reactlog
rea

github.com/matejb/reactlog

Package reactLog is reaction middle-ware for standard golang log

by Matej Baćo

v0.0.0-20151010144931-091f1c350d6c (see all)License:MIT
go get github.com/matejb/reactlog
Readme

reactLog

Package reactLog is reaction middle-ware for standard golang log.

Build Status Code Coverage Documentation

Basic usage:

reactLogger := reactLog.New(os.Stderr)

copyBuf := &bytes.Buffer{}
reactLogger.AddReaction("user ID 85", &reactLog.Copy{copyBuf})

log.SetOutput(reactLogger)

log.Println("This is regular log message")
log.Println("This error message concers user ID 85 and will be copied to copyBuf.")

reactLog concept is to filter and add additional functionality to log based on log message content.

If used in main package it enhance log globally with the use of log.SetOutput method.

Any number of trigger words can be registered using AddReaction method each with it's own Reactor.

Reactor is the interface that wraps the Reaction method. reactLog comes with few types that already implements Reactor interface:

  • Discard for discarding log messages.
  • Redirect to redirect log messages to other io.Writer.
  • Copy to write log message both to underlying io.Writer and additional io.Writer.

Feel free to create Reactors for you specific use case by implementing Reactor interface.

See Documentation for more info.

GitHub Stars

11

LAST COMMIT

7yrs ago

MAINTAINERS

0

CONTRIBUTORS

2

OPEN ISSUES

0

OPEN PRs

0
VersionTagPublished
v0.0.0-20151010144931-091f1c350d6c
2yrs ago
No alternatives found
No tutorials found
Add a tutorial