new EventLog(options)
Constructor for EventLog
Parameters:
Name |
Type |
Description |
options |
object
|
Options for the event log
Properties
Name |
Type |
Attributes |
Description |
consoleLevel |
string
|
<optional>
|
The level at which to log to the
events to the console. Must be one of the LEVELS or false to prevent all
console logging. |
analyticsModel |
Backbone.Model
|
<optional>
|
An existing analytics
model to use for sending log events. If not provided, a new Analytics
model will be created. |
maxEvents |
number
|
<optional>
|
Maximum number of events per log.
Defaults to 500. |
|
- Source:
Methods
clearLog(log)
Clear all events from a log, resetting its state.
Parameters:
Name |
Type |
Description |
log |
object
|
The log object to clear |
- Source:
consoleLog(message, logNameopt, levelopt, metaopt)
Log an event to the console with a prefix indicating the log name.
Parameters:
Name |
Type |
Attributes |
Default |
Description |
message |
string
|
|
|
The log message |
logName |
object
|
<optional>
|
Default Log
|
The log object containing the log name |
level |
"info"
|
"warning"
|
"error"
|
<optional>
|
info
|
The log level |
meta |
object
|
<optional>
|
|
Optional metadata to include with the log |
- Source:
getOrCreateLog(name) → {object}
Create a new collection to record events related by context or scope. If
a log with the same name already exists, it will return the existing log.
Parameters:
Name |
Type |
Description |
name |
string
|
Label and ID for the log. If not provided, the
default log will be used. |
- Source:
Returns:
- The log object containing an ID, name, start time,
and events.
-
Type
-
object
log(log, level, message, metaopt)
Record an event to the specified log with a given level.
Parameters:
Name |
Type |
Attributes |
Description |
log |
object
|
|
The log object to record the event in |
level |
"info"
|
"warning"
|
"error"
|
|
Log level, must be in LEVELS |
message |
string
|
|
The log message |
meta |
object
|
<optional>
|
Optional metadata to include with the log |
- Source:
sendToAnalytics(log, eventNameopt)
Manually send a log to analytics (e.g., GA)
Parameters:
Name |
Type |
Attributes |
Default |
Description |
log |
object
|
|
|
The log object to send |
eventName |
string
|
<optional>
|
EventLog
|
The name of the event to send to analytics |
- Source:
Example
sendToAnalytics(
resMapResolver.getLog(pid),
"resource_map_resolution_failed"
);
setAnalyticsModel(analyticsModel)
Optionally attach a specific analytics model (e.g. GoogleAnalytics)
Parameters:
Name |
Type |
Description |
analyticsModel |
Backbone.Model
|
An existing analytics model to
use for sending log events. |
- Source:
setConsoleLogLevel(level)
Set the console log level for this EventLog instance.
Parameters:
Name |
Type |
Description |
level |
string
|
boolean
|
The log level to set. Must be one of the
LEVELS (info, warning, error) or false to disable console logging. |
- Source:
Throws:
-
If an invalid level is provided.
-
-
Type
-
Error
getLogs(log) → {Array.<object>}
Return a log's full log for inspection
Parameters:
Name |
Type |
Description |
log |
object
|
The log object to inspect |
- Source:
Returns:
- Array of log events
-
Type
-
Array.<object>