-
Notifications
You must be signed in to change notification settings - Fork 57
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
feat: use NODE_ENV and cds.env.features.kibana_formatter for format #2481
feat: use NODE_ENV and cds.env.features.kibana_formatter for format #2481
Conversation
There are following cases:
There are potentially some problems though and I need your thoughts on these:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not depend on CDS, I think this might not have been clear enough in the ticket.
[fixed] Thanks for the feedback. I removed the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for taking so long. Please read my comment about scope creep ;) and add the interface and the getter. 😊
@@ -49,7 +63,7 @@ export function unmuteLoggers(): void { | |||
*/ | |||
export const cloudSdkExceptionLogger = container.get(exceptionLoggerId, { | |||
defaultMeta: { logger: loggerReference, test: 'exception' }, | |||
format, | |||
format: container.options.format, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[q] Shouldn't the format of the SDK exception logger be the same as for other logs?
/** | ||
* Change the log format of a logger based on its message context. | ||
* e.g., to set the log format for the destination accessor module of the SDK to `local`, simply call `setLogFormat(logFormat.local, 'destination-accessor')`. | ||
* @param format - Format to set the logger to. Use `logFormat` to get the pre-defined log formats or use a custom log format. | ||
* @param messageContextOrLogger - Message context of the logger to change the log level for or the logger itself. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nth] This is more than required by the original issue (scope creep) and usually we shouldn't allow for this, because this can cause some problems down the line (e.g. because the API was not aligned, did we consider that whether there are any features that could break because of this, etc.).
Anyways, I discussed this with @FrankEssenberger at length yesterday and we agreed that for this case we will keep it.
The reason I am mentioning this, is that currently users don't have the possibility to change the log format at all and with this we are opening up a new feature, that f.e. depends on types from the logform
lib.
[req] We usually introduce our own compatible interfaces, we should do the same for the Format
. @jjtang1985 could you show an example?
[req] If we have set global, get global, set single, I guess we also need get single?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discuessed, I think the requested changes are not necessary given the current state of the loggers. Let's stay consistent for now and make improvements later.
Closes SAP/cloud-sdk-backlog#380.
We implemented
setLogFormat
andsetGlobalLogFormat
in this ticket similar to log level. The defaultlocal
andkibana
format is exported withlogFormat
. Now, users can specify a log format both from the default two or even their customized formatters.NODE_ENV
is used to determine the initial log format:production
->kibana
,local
otherwise. This can be overwritten by the aforementioned two setters.