Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

string interpolation is not working with local format #2449

Open
zpq2004 opened this issue May 5, 2022 · 1 comment
Open

string interpolation is not working with local format #2449

zpq2004 opened this issue May 5, 2022 · 1 comment
Labels
feature request Requests for new functionality prio: low

Comments

@zpq2004
Copy link

zpq2004 commented May 5, 2022

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"

@deekshas8
Copy link
Contributor

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

@jjtang1985 jjtang1985 added feature request Requests for new functionality prio: low labels Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Requests for new functionality prio: low
Projects
None yet
Development

No branches or pull requests

3 participants