# new Logger(coreObj) → {Server.Modules.Logger}
This is the Logger Module of the Blackrock Application Server. It provides a logging method that can be used throughout the framework / application server, as well as directly from within apps. It has routing capabilities, allowing log events to be routed to - the Console, a Log File on the filesystem, ElasticSearch and emitted directly to the Core Module instance.
Name | Type | Description |
---|---|---|
coreObj |
Server.Modules.Core | The Core Module Singleton |
- Copyright:
- Copyright (c) 2021 Darren Smith
- License:
- Licensed under the LGPL license.
- Source:
module - The Logger Module Singleton
const loggerModule = req.core.module('logger');
Extends
Members
# (static) mod.analytics
This method is used internally to track server analytics such as up time, total and average number of requests and responses going through the Router Module, Etc...
Properties
Name | Type | Description |
---|---|---|
log |
function | Log Method |
- Source:
Example
Tbc...
Methods
# (static) getLatestHeartbeat() → {object}
Tbc...
- Source:
latestHeartbeat - The Latest Heartbeat
- Type
- object
Tbc...
# (static) log(level, logMsg, attrObjopt, evtNameopt) → {boolean}
This method is the main method used to log new events in the Blackrock Application Server. You must pass it a 'level' (startup|error|warning|debug|[custom]) and message at a minimum. The Attributes Object and Event Name are optional.
Name | Type | Attributes | Description |
---|---|---|---|
level |
string | Log Level (startup|error|warning|debug|[custom]) |
|
logMsg |
string | Log Message |
|
attrObj |
object |
<optional> |
Attributes Object |
evtName |
string |
<optional> |
Event Name |
- Source:
result - Result (True|False)
- Type
- boolean
const log = req.core.module('logger').log;
log('debug', 'This is a sample message', {type: "sample"}, 'SAMPLE_MSG');
// If Console Enabled, Output Is: 'XXXX-XX-XX XX-XX-XX (debug) This is a sample message'