Logger

Server.Modules. Logger

# 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.

Parameters:
Name Type Description
coreObj Server.Modules.Core

The Core Module Singleton

Author:
  • Darren Smith
License:
  • Licensed under the LGPL license.
Returns:

module - The Logger Module Singleton

Type
Server.Modules.Logger
Example
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

Example
Tbc...

Methods

# (static) getLatestHeartbeat() → {object}

Tbc...

Returns:

latestHeartbeat - The Latest Heartbeat

Type
object
Example
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.

Parameters:
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

Returns:

result - Result (True|False)

Type
boolean
Example
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'