Skip to content

Package reactLog is reaction middle-ware for standard golang log

License

Notifications You must be signed in to change notification settings

matejb/reactLog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Package reactLog is reaction middle-ware for standard golang log

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages