Log bridge, which is an EventEmitter that sends events to one or more outputs/loggers. Setup these loggers by specifying their config as the first argument, or by passing it to addOutput().

Uses

Constructor

Log (output)

Defined in src/lib/log.js:4

Parameters:

output String | Object | ArrayOfStrings | ArrayOfObjects
  • Either the level to setup a single logger, a full config object for alogger, or an array of config objects to use for creating log outputs.

Methods

addOutput (config)

Logger

Defined in src/lib/log.js:142

Create a new logger, based on the config.

Parameters:

config Object
  • An object with config options for the logger.

Returns:

Logger:

cleanUpListeners ()

Undefined private

Clear the current event listeners

Returns:

Undefined:

debug (msg)

Boolean

Defined in src/lib/log.js:205

Log a debug level message

Parameters:

msg...
  • Any amount of messages that will be joined before logged

Returns:

Boolean:
  • True if any outputs accepted the message

error (error)

Boolean

Defined in src/lib/log.js:164

Log an error

Parameters:

error Error | String

The Error to log

Returns:

Boolean:
  • True if any outputs accepted the message

info (msg)

Boolean

Defined in src/lib/log.js:192

Log useful info about what's going on

Parameters:

msg...
  • Any amount of messages that will be joined before logged

Returns:

Boolean:
  • True if any outputs accepted the message

join (arrayish)

String private static

Defined in src/lib/log.js:123

Combine the array-like param into a simple string

Parameters:

arrayish
  • An array like object that can be itterated by _.each

Returns:

String:
  • The final string.

onDebug (msg)

Undefined private

Handler for the bridges "debug" event

Parameters:

msg String
  • The message to be logged

Returns:

Undefined:

onError (e)

Undefined private

Handler for the bridges "error" event

Parameters:

e Error
  • The Error object to log

Returns:

Undefined:

onInfo (msg)

Undefined private

Handler for the bridges "info" event

Parameters:

msg String
  • The message to be logged

Returns:

Undefined:

onTrace (msg)

Undefined private

Handler for the bridges "trace" event

Parameters:

msg String
  • The message to be logged

Returns:

Undefined:

onWarning (msg)

Undefined private

Handler for the bridges "warning" event

Parameters:

msg String
  • The message to be logged

Returns:

Undefined:

parseLevels (input)

Array private static

Defined in src/lib/log.js:105

Converts a log config value (string or array) to an array of level names which it represents

Parameters:

input String | ArrayOfStrings
  • Cound be a string to specify the max level, or an array of exact levels

Returns:

Array:

-

requestTrace (method, url, body, responseStatus, responseBody)

Boolean

Defined in src/lib/log.js:231

Shortcut for formatting a response trace message, which won't go through the trouble of formatting the message if nothing will be receiving the message.

Parameters:

method String
  • The HTTP method from the request
url String
  • The URL from the request
body String
  • The JSON body from the request
responseStatus String
  • The HTTP response's status code
responseBody String
  • The HTTP response's body

Returns:

Boolean:
  • True if any outputs accepted the message

setupListeners (level)

Undefined private

Clear the current event listeners and then re-listen for events based on the level specified

Parameters:

level Integer
  • The max log level that this logger should listen to

Returns:

Undefined:

trace (msg)

Boolean

Defined in src/lib/log.js:218

Log a trace level message

Parameters:

msg...
  • Any amount of messages that will be joined before logged

Returns:

Boolean:
  • True if any outputs accepted the message

warning (msg)

Boolean

Defined in src/lib/log.js:178

Log a warning message

Parameters:

msg...
  • Any amount of messages that will be joined before logged

Returns:

Boolean:
  • True if any outputs accepted the message

write (to, label, colorize, what)

Undefined private

Sends output to a stream, does some formatting first

Parameters:

to WriteableStream
  • The stream that should receive this message
label String
  • The text that should be used at the begining of the message
colorize Function
  • A function that recieves a string and returned a colored version of it
what
  • The message to log

Returns:

Undefined:

Properties

levels

Array static

Defined in src/lib/log.js:51

Levels observed by the loggers, ordered by rank

Events

debug

Defined in src/lib/log.js:82

Event fired for "debug" level log entries, which will describe requests sent, including their url (no data, response codes, or exec times)

Event Payload:

  • message String
    • A message to be logged

error

Defined in src/lib/log.js:59

Event fired for error level log entries

Event Payload:

  • error Error
    • The error object to log

info

Defined in src/lib/log.js:74

Event fired for "info" level log entries, which usually describe what a client is doing (sniffing etc)

Event Payload:

  • message String
    • A message to be logged

trace

Defined in src/lib/log.js:90

Event fired for "trace" level log entries, which provide detailed information about each request made from a client, including reponse codes, execution times, and a full curl command that can be copied and pasted into a terminal

Event Payload:

  • params Object
    • status Number
      • the HTTP response code from the request
    • url String
      • The URL from the request
    • request_body String
      • The body of the request
    • response_body String
      • The body of the response

warning

Defined in src/lib/log.js:65

Event fired for "warning" level log entries, which usually represent things like correctly formatted error responses from ES (400, ...) and recoverable errors (one node unresponsive)

Event Payload:

  • message String
    • A message to be logged