Tutorial Source Code |
Examples referenced:
|
Last Update | March 2022 |
Compiler/Runtime | See Getting Started with TypeScript. |
Pre-requisites | Enable the session environment as outlined within the Getting Started guide. |
The typescript library uses the loglevel package for the logging purposes. A few of the logging control methods from this package are exposed in the code. Other aspects of the logging can be configued using the TS Library Config file.
To change the default level of all the TS library modules, use the logger setLevel command like this:
// import the logger package
import { logger } from '@refinitiv-data/data';
// change the logging level to TRACE, DEBUG, INFO, WARN, ERROR, SILENT
logger.setLevel(logger.levels.DEBUG);
Additionally, a user can enable or disable all the logging (file and console) output using a single function:
// enable the file and console logger
logger.enableAll();
// send a custom warning message from the application
logger.warn('This is a WARNING message');
Granular level of logging can also be configured in the Typescript library configuration file. It can configure the logging level, logging modules and also controls for individual logger outputs like console and file and filename.
Here is an example of logs section of the config file which enables console output for Warning messages only:
{
"logs": {
"level": "warn",
"filter": "*",
"transports": {
"console": {
"enabled": true
},
"file": {
"enabled": false,
"name": "tsliblog"
}
}
}
}
This tutorial was meant as a quick introduction to the basic logging methods available in the library. We encourage the use of IntelliSense documentation within your Visual Studio editor to discover other useful capabilities.