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:
# Log settings
const configuration = { logLevel: 0};
//const configuration = { logLevel: 1 };

Custom logger configuration

You can set the logger configuration to control what, if anything, gets logged.

// logLevel: 0: only error gets logged (default), 1: debugging info gets logged
// logIsOn: when false, do not log. True by default, you can override dynamically 
    to log data only for certain calls (for example by checking for a specific payload)
// logPerfData: when true, will log performance data
// logRulesStatements: when true, will write rule statements to the log
// logFunction: Used to implement your own logger. When defined this function
	is called with a string message to log and an error level.
								
const configuration = { logLevel: 0 };

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:
function myLogger(msg, logLevel) {
    if ( logLevel === 0 )
        console.error(`**CUSTOM ERROR LOGGER: ${msg}`);
    else
        console.info(`**CUSTOM DEBUG LOGGER: ${msg}`);
}		
Then you declare that you want to use a custom logger with the logFunction setting:
/*
const configuration = logFunction; { logLevel: 1 }							

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.

Logging has just two levels: 0: only errors get logged (default), 1: debugging info gets logged.

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.

/*
function isLogOnForThisPayload(payload) {
	let flag;
	try {
		if ( payload.Objects[0]['int1'] === 1 )
			flag = true;
		else
			flag = false;
	}
	catch ( e ) {
		console.log (`Error in isLogOnForThisPayload: ${e}\n`);
		flag = true;
	}
	console.log(`isLogOnForThisPayload: ${flag}\n`); 
	return flag;
}