string interpolation is not working with local format
Hi,
I'm trying to use the Logger interface by following https://sap.github.io/cloud-sdk/docs/js/features/logging, as mentioned The SAP Cloud SDK sets default values for format and transports parts. The transport is set to console and the format is set to local or kibana.
Since I'm running the application locally without VCAP_SERVICE variable, I assume that it is using local as format.
Here is part of the code.
const { createLogger } = require('@sap-cloud-sdk/util');
const logger = createLogger('saas-registry');
logger.log('info', '%s', 'abc');
It output the message as below. The string interpolation is not working here.
[2022-05-05T08:47:56.784Z] INFO (saas-registry): %s
If I used winston module directly:
const { createLogger, format, transports } = require('winston');
const logger = createLogger({
defaultMeta: { service: 'saas-registry' },
format: format.combine(
format.splat(),
format.simple()
),
transports: [new transports.Console()]
});
logger.log('info', '%s', 'abc');
It output the message as below and the string interpolation worked:
info: abc {"service":"saas-registry"}
Version information @sap-cloud-sdk/core ==> "version": "1.54.0" @sap/cds ==> "version": "5.9.2"
Hi @zpq2004 ,
Thanks for raising this. The SDK logger's formats currently do not support string interpolation by default. I will create a backlog item for this.
FYI @marikaner
Regards, Deeksha