Description
Right now you have to set the log level via the constructor like so:
const aioLogger = require('@adobe/aio-lib-core-logging')('App', { level: 'info' })
function main (params) {
// you can't set the log level here, it is already fixed to `info` above
// thus .debug won't output anything
aioLogger.debug('this will not output anything')
}
Proposed setLogLevel feature
const aioLogger = require('@adobe/aio-lib-core-logging')('App')
function main (params) {
// the log level is by default `info` and you can't change it after construction,
// unless you add this feature like so
aioLogger.setLogLevel(params.LOG_LEVEL)
// if params.LOG_LEVEL was 'debug', now debug logs will show in the output
aioLogger.debug('this will output if params.LOG_LEVEL is debug')
}
Workaround
The workaround is to create the logger with the log level, in your function scope.
const coreLogger = require('@adobe/aio-lib-core-logging')
function main (params) {
const aioLogger = coreLogger('App', { level: params.LOG_LEVEL })
// if params.LOG_LEVEL was 'debug', debug logs will show in the output
aioLogger.debug('this will output if params.LOG_LEVEL is debug')
}
Description
Right now you have to set the log level via the constructor like so:
Proposed
setLogLevelfeatureWorkaround
The workaround is to create the logger with the log level, in your function scope.