Log Class
Defined in:src/lib/log.js:4
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)
Parameters:
output
|
String | Object | ArrayOfStrings | ArrayOfObjects |
|
Methods
addOutput
(config)
Logger
Create a new logger, based on the config.
Parameters:
config
|
Object |
|
Returns:
cleanUpListeners
()
Undefined
private
Clear the current event listeners
Returns:
debug
(msg)
Boolean
Log a debug level message
Parameters:
msg...
|
|
Returns:
- True if any outputs accepted the message
error
(error)
Boolean
Log an error
Parameters:
error
|
Error | String |
The Error to log |
Returns:
- True if any outputs accepted the message
info
(msg)
Boolean
Log useful info about what's going on
Parameters:
msg...
|
|
Returns:
- True if any outputs accepted the message
join
(arrayish)
String
private
static
Combine the array-like param into a simple string
Parameters:
arrayish
|
|
Returns:
- The final string.
onDebug
(msg)
Undefined
private
Handler for the bridges "debug" event
Parameters:
msg
|
String |
|
Returns:
onError
(e)
Undefined
private
Handler for the bridges "error" event
Parameters:
e
|
Error |
|
Returns:
onInfo
(msg)
Undefined
private
Handler for the bridges "info" event
Parameters:
msg
|
String |
|
Returns:
onTrace
(msg)
Undefined
private
Handler for the bridges "trace" event
Parameters:
msg
|
String |
|
Returns:
onWarning
(msg)
Undefined
private
Handler for the bridges "warning" event
Parameters:
msg
|
String |
|
Returns:
parseLevels
(input)
Array
private
static
Converts a log config value (string or array) to an array of level names which it represents
Parameters:
input
|
String | ArrayOfStrings |
|
Returns:
-
requestTrace
(method, url, body, responseStatus, responseBody)
Boolean
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 |
|
url
|
String |
|
body
|
String |
|
responseStatus
|
String |
|
responseBody
|
String |
|
Returns:
- 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 |
|
Returns:
trace
(msg)
Boolean
Log a trace level message
Parameters:
msg...
|
|
Returns:
- True if any outputs accepted the message
warning
(msg)
Boolean
Log a warning message
Parameters:
msg...
|
|
Returns:
- 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 |
|
label
|
String |
|
colorize
|
Function |
|
what
|
|
Returns:
Properties
levels
Array
static
Levels observed by the loggers, ordered by rank
Events
debug
Event fired for "debug" level log entries, which will describe requests sent, including their url (no data, response codes, or exec times)
Event Payload:
-
messageString- A message to be logged
error
Event fired for error level log entries
Event Payload:
-
errorError- The error object to log
info
Event fired for "info" level log entries, which usually describe what a client is doing (sniffing etc)
Event Payload:
-
messageString- A message to be logged
trace
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:
-
paramsObject-
statusNumber- the HTTP response code from the request
-
urlString- The URL from the request
-
request_bodyString- The body of the request
-
response_bodyString- The body of the response
-
warning
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:
-
messageString- A message to be logged