Skip to main content

Logging

The TIM API is able to log an extensive set of events and actions within the TIM API. It's key that logs are created and stored properly. Logging enables support and makes bug-tracking much easier.

By default the TIM API JavaScript logs to the webconsole of the corresponding browser used, or to the system shell in case of Node.js. Due to security restrictions in the web context no log-files are created locally. Nevertheless, the TIM API JavaScript offers the possibility that the integrator can overwrite this behaviour by using the onTimApiPublishLogRecord(logRecord) or the onTimApiLog(message) method. If the TIM API JavaScript is used in web context it is recommended that the log message shall be sent to a log server or alike. If used with Node.js the message can be written into a file locally, as there are not such security restrictions in conjunction with Node.js.

The onTimApiPublishLogRecord(logRecord) function can be used if the user wants to filter certain log messages. The log entry is transmitted in a LogRecordobject that includes several information about the log entry. The user then can filter the entry e.g. regarding the logLevel and may then use the Log function to log the message accordingly, if wished so.

/*
* Function to filter certain log records according
* some information given in parameter "record", e.g. LogLevel.
*/
onTimApiPublishLogRecord = function (record) {
// Do some filtering if wished so.
if (!record.matchesLevel(timapi.LogRecord.LogLevel.info)) {
return;
}
// timapi.log() will call the onTimApiLog function
timapi.log(String(record));
}

The onTimApiLog(message) method is used with a string message as log entry, not with an object. This method should be used to redirect the standard console logging e.g. to a log server or to a local file in case of Node.js.

/**
* Function will be called, when timapi has a log message
*/
onTimApiLog = function(message) {
/* Send message to log server or alike
* or write it into a log file if Node.js
*/ is used.
}

Attention: If this function is used, the default behaviour will not be performed by the TIM API and no console logging is done.