Class: RedisEventCache

transports~RedisEventCache

new RedisEventCache(options)

Custom Redis "Event" logging transport for Winston.

Internally, it uses Redis' built-in pub/sub messaging feature to notify its listener method when the cache is ready to be purged.

You would log SOME_EVENT type events to the table "test_events" using the following call to the log method:

logger.log("info", msg, {type: "SOME_EVENT, val2: "a val", val2: "another val"})

IMPORTANT: If the meta key type is not found, or the given type is not configured in the provided config file, the event will be ignored in this transport.

Parameters:
Name Type Description
options Object

options object

Properties
Name Type Attributes Default Description
level String <optional>
"info"

logging level

timestamp Boolean <optional>
true

whether to include UTC timestamp field in log row.

redis_host String <optional>
'127.0.0.1'

host for redis client

redis_port Number <optional>
6379

port for redis client.

redis_options Object <optional>
{}

options for redis client.

eventStreamer EventStreamer <optional>
EventStreamer()

EventStreamer instance for specific datastore

eventSchema Object <optional>

Object where keys = event_types and values = Array of fields for each type. If not provided, will try to get this from this.evenStreamer.getEventSchema method. If provided, will override whatever this method returns. NOTE: To return ALL keys from logged meta object, use special value {"event_type": "*"}

Source:

Methods

log(level, msg, meta, callback)

Base logger method.

Ignores any messages without type field present in meta object, or with a type not configured in this.event_types.

Otherwise, parses log message and metadata and sends to this._addRowtoCache, where all the caching logic is taken care of.

NOTE: also augments all loglines with "hostname" field

Parameters:
Name Type Description
level
msg
meta
callback
Source: