EventLogger

EventLogger

new EventLogger()

Source:

Tiny utility class to provide generic, subscriber-style logging services for packages designed to be imported into other application projects.

Rather than include a massive logging dependency in package.json, this allows a developer to selectively listen for important package events at the application-level, and log them if desired. Because there will be a difference in time between when a package is loaded and firing events, and when an application is actually ready to listen for those events, an internal circular buffer of up to 100 events is kept. When, and if, a listener is added by the application then the buffer is drained and bypassed.

Loosely inspired by how Java dependencies reference the sl4j API as a generic logging interface, but never actually reference an entire logging library.

Extends

  • EventEmitter

Methods

log(message, metadata)

Source:

Helper function to emit a log event

Parameters:
Name Type Description
message String

The log message

metadata Object

Related metadata (if any)