Caplin Trader 5.1.0

Class: module:ct-core/log/StoreLogger

module:ct-core/log/StoreLogger(level, maxRecords)

A module:ct-core/log/Logger that stores log messages into internal arrays.

Constructor

new module:ct-core/log/StoreLogger(level, maxRecords)

Constructs a StoreLogger.

Extends:
Parameters:
Name Type Description
level

the most detailed level at which to output log messages. Should be one of the levels defined statically on module:ct-core/log/AbstractLogger. Will default to INFO level if not provided.

maxRecords Number

an integer larger than 0 which is the maximum number of records to retain. If this parameter is not provided, then all records will be retained. This will create a memory leak if you do not periodically call clear.

Extends

Methods

addListener(callback) → {Number}

Adds a listener the that will be notified if the stored contents changes.

Parameters:
Name Type Description
callback function

The function that will be called on any changes.

Inherited From:
Returns:

An id for the listener that can be used to remove it (see module:ct-core/log/LogStoreService#removeListener).

Type
Number

clear()

Clears all stored log records.

Inherited From:

debug()

Log a 'debug' message. A variable argument method. See module:ct-core/log/Log.interpolate for more information.

Inherited From:

error()

Log an 'error' message. A variable argument method. See module:ct-core/log/Log.interpolate for more information.

Avoid using this method, as it is intended only to be used at the top level.

Inherited From:

getAllLogRecords() → {Array}

Retrieves all stored log records.

Inherited From:
Returns:

an array of module:ct-core/log/LogRecords. Will not be null.

Type
Array

getLogRecord(n) → {module:ct-core/log/LogRecord}

Retrieves a stored log record.

Parameters:
Name Type Description
n Number

the index of the log record to be retrieved.

Inherited From:
Returns:

the nth oldest LogRecord (0 indexed) or undefined if n refers to a log record that hasn't been stored.

Type
module:ct-core/log/LogRecord

getSize() → {Number}

Inherited From:
Returns:

The number of stored log records.

Type
Number

info()

Log an 'info' message. A variable argument method. See module:ct-core/log/Log.interpolate for more information.

Inherited From:

removeListener(id)

Adds a listener the that will be notified if the stored contents changes.

Parameters:
Name Type Description
id Number

The id of the listener to be removed (see module:ct-core/log/LogStoreService#addListener).

Inherited From:

trace()

Log a 'trace' message. A variable argument method. See module:ct-core/log/Log.interpolate for more information.

Inherited From:

warn()

Log a 'warn' message. A variable argument method. See module:ct-core/log/Log.interpolate for more information.

Inherited From:

(inner) addListener() → {Number}

Returns:

The number of log messages stored.

Type
Number

(inner) clear()

Clears all log records that have been stored in this StoreLogger.

(inner) dump() → {String}

Provides all of the stored log information as a string.

Returns:

a string containing all the logged records.

Type
String

(inner) getAllLogRecords() → {Array}

Provides all of the stored log information.

Returns:
Type
Array

(inner) getLogRecord(n) → {module:ct-core/log/LogRecord}

Retrieves a stored log record.

Parameters:
Name Type Description
n Number

the index of the log record to be retrieved.

Returns:

the nth oldest LogRecord (0 indexed) or undefined if n refers to a log record that hasn't been stored.

Type
module:ct-core/log/LogRecord

(inner) getSize() → {Number}

Returns:

The number of log messages stored.

Type
Number

(inner) log(level, logData)

Stores the time and all the log information internally.

Parameters:
Name Type Description
level String

the name of the method that was called.

logData Array

the log information.

(inner) register(classPatternopt)

Registers this logger as a module:ct-core/log/LogStoreService with the ServiceRegistry and as a module:ct-core/log/Logger with the EventHub (to receive log messages).

Parameters:
Name Type Attributes Description
classPattern String <optional>

a pattern to restrict which messages the logger receives.

(inner) removeListener() → {Number}

Returns:

The number of log messages stored.

Type
Number