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

feat(framework): Control logging #7475

Open
wants to merge 3 commits into
base: next
Choose a base branch
from

Conversation

SokratisVidros
Copy link
Contributor

What changed? Why was the change needed?

Add coarse-graining logging control and test logs to prevent flooding production.

This is the first step in switching on/off framework logging so we can use it in production and e2e tests. In future work, we need to add logging levels and log differently in development (log everything) and production (log only errors and a summary of the discovered workflows).

Copy link

netlify bot commented Jan 9, 2025

Deploy Preview for dashboard-v2-novu-staging ready!

Name Link
🔨 Latest commit 964dcc5
🔍 Latest deploy log https://app.netlify.com/sites/dashboard-v2-novu-staging/deploys/67c02e07b3c9a5000856bf38
😎 Deploy Preview https://deploy-preview-7475.dashboard-v2.novu-staging.co
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jan 9, 2025

Deploy Preview for dev-web-novu ready!

Name Link
🔨 Latest commit 964dcc5
🔍 Latest deploy log https://app.netlify.com/sites/dev-web-novu/deploys/67c02e07b64ced00084407e2
😎 Deploy Preview https://deploy-preview-7475.dashboard.novu-staging.co
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

pkg-pr-new bot commented Jan 9, 2025

Open in Stackblitz

npm i https://pkg.pr.new/novuhq/novu/@novu/framework@7475
npm i https://pkg.pr.new/novuhq/novu@7475

commit: 964dcc5

@SokratisVidros SokratisVidros marked this pull request as ready for review February 27, 2025 20:26
// eslint-disable-next-line no-console
console.error(bridgeError);
// eslint-disable-next-line @typescript-eslint/no-base-to-string
log((l) => l.error(bridgeError.message || bridgeError.toString()));
Copy link
Contributor

Choose a reason for hiding this comment

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

feels a bit complex and not the usual format of logging. what are the cons of doing something like this?

Suggested change
log((l) => l.error(bridgeError.message || bridgeError.toString()));
log.error(bridgeError.message || bridgeError.toString());

in case of

    log((l) => `${prefix} ${l.emoji.STEP} Discovered stepId: '${step.stepId}'\tType: '${step.type}'`);

we could do

    log.info(`${prefix} ${log.emoji.STEP} Discovered stepId: '${step.stepId}'\tType: '${step.type}'`);

the formatting should be the responsibility of the logger user; this way, it is easier to read. in addition, having the default log level hidden is a bit confusing and not straightforward.

@@ -72,21 +73,31 @@ export class Client {

public strictAuthentication: boolean;

public logging: boolean = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public logging: boolean = true;
public loggingEnabled | isLoggingEnabled: boolean = true;

Comment on lines +73 to +77
log.enable = () => {
enabled = true;
};
log.disable = () => {
enabled = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

👏

}

// Disable verbose logging in test and production environments
return !['test', 'production'].includes(process.env.NODE_ENV);
Copy link
Contributor

Choose a reason for hiding this comment

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

Love it!
But can't we reuse NOVU_LOGGING to toggle this? so for test and prod it will be false, but in case we want to debug some edge cases, we could turn it on in prod.
in addition, we could use more specific env variables so they won't collide in the future in any way FRAMEWORK_LOGGING, although it should not be an issue.

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

Successfully merging this pull request may close these issues.

2 participants