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

BREAKING CHANGE: add support to log tenantId #17

Merged
merged 6 commits into from
Dec 13, 2022

Conversation

Substancia
Copy link
Contributor

package.json Outdated
@@ -1,6 +1,6 @@
{
"name": "logger-safe-security",
"version": "1.2.1",
"version": "1.2.2",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert this change. We have auto-release configured.

src/index.ts Outdated
info.tenantId = valueFromMethod<string>("tenantId");
}
} catch (error) {
console.error(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the error log.

src/index.ts Outdated
/* A custom format that is used to include tenantId. */
const formatTenantId = (parameters: ParameterConfig | undefined) => {
return winston.format(info => {
info.tenantId = "";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this as well. If we get tenantId from the context then use it, else make no changes.

@@ -18,16 +27,44 @@ const formatError = winston.format(info => {
return info;
});

/* A custom format that is used to include tenantId. */
const formatTenantId = (parameters: ParameterConfig | undefined) => {
return winston.format(info => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove the dependency on the tenantId and make this generic?
From the parameters config, get the keys, check if the key is present in the store, if yes, add it to info else skip.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the PR title with breaking changes.

@Substancia Substancia changed the title Adding support to log tenantId feat: added support to log tenantId Dec 8, 2022
@Substancia Substancia changed the title feat: added support to log tenantId BREAKING CHANGE: add support to log tenantId Dec 8, 2022
@Substancia
Copy link
Contributor Author

To test this:-

New createLogger method call in <container>/src/config/logger.ts is

const logger = createLogger({
    logLevel: APP_LOG_LEVEL,
    service: process.env.SERVICE_NAME,
    config: {
        parameters: {
            tenantId: {
                valueFromMethod: getValueFromStore
            }
        }
    }
});

Copy link
Contributor

@aneeshrelan aneeshrelan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aneeshrelan aneeshrelan merged commit 1d022c7 into Safe-Security:main Dec 13, 2022
github-actions bot pushed a commit that referenced this pull request Dec 13, 2022
# [2.0.0](v1.2.1...v2.0.0) (2022-12-13)

### Features

* add support to log additional attributes by default ([#17](#17)) ([1d022c7](1d022c7))

### BREAKING CHANGES

* add arbitrary parameters to be part of every log line by default
@github-actions
Copy link

🎉 This PR is included in version 2.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants