How to use logging and diagnostics
- Last Updated: March 24, 2023
- 1 minute read
- Corticon.js
- Documentation
Default logging
Corticon.js decisions services will, by default, log messages to the default
output of the platform, which is, for most JavaScript platforms, the JavaScript console.
On other platforms, it is a context or similar object that the platform provides for
directing logging. For the browser example where the platform is HTML, the
browser.sample.html file has lines:
|
Custom logger configuration
You can set the logger configuration to control what, if anything, gets logged.
|
Custom logger
Each sample includes a simple logger where 1: log error and 2: log debug
data. Your might want to log to a preferred destination, such as into a database. To do
that, you specify a custom logger:
|
Then you declare that you want to use a custom logger with the
logFunction setting:
|
Basic logging
Each wrapper includes a sample configuration for logger that is a
function you can override dynamically when to log data. It is useful for tracing only
certain calls (for example by checking for a specific payload) This function is
optional. When you pass a simple configuration without the logIsOn property you do not need to define this function.
Filtered logging
Log entries can produce a lot of data, especially in debug mode. You can
dynamically override when to log data, such as tracing only certain calls or payload
attribute values. When you pass a simple configuration without the logIsOn property you don't need to define this property.
|