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: added debug flag in the SuperTokenConfig in the init() for logging #732

Merged
merged 10 commits into from
Oct 31, 2023

Conversation

IamMayankThakur
Copy link
Contributor

@IamMayankThakur IamMayankThakur commented Oct 26, 2023

Summary of change

  • Added debug flag in the init(). Debug logs will be printed if this flag is set to true.
  • The old way of settings the environment variable DEBUG=com.supertokens will continue to work.

Related issues

  • Link to issue1 here
  • Link to issue1 here

Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Bonus points for screenshots and videos!)

Documentation changes

(If relevant, please create a PR in our docs repo, or create a checklist here highlighting the necessary changes)

Checklist for important updates

  • Changelog has been updated
  • coreDriverInterfaceSupported.json file has been updated (if needed)
    • Along with the associated array in lib/ts/version.ts
  • frontendDriverInterfaceSupported.json file has been updated (if needed)
  • Changes to the version if needed
    • In package.json
    • In package-lock.json
    • In lib/ts/version.ts
  • Had run npm run build-pretty
  • Had installed and ran the pre-commit hook
  • If new thirdparty provider is added,
    • update switch statement in recipe/thirdparty/providers/configUtils.ts file, createProvider function.
    • add an icon on the user management dashboard.
  • Issue this PR against the latest non released version branch.
    • To know which one it is, run find the latest released tag (git tag) in the format vX.Y.Z, and then find the latest branch (git branch --all) whose X.Y is greater than the latest released tag.
    • If no such branch exists, then create one from the latest released branch.
  • If have added a new web framework, update the add-ts-no-check.js file to include that
  • If added a new recipe / api interface, then make sure that the implementation of it uses NON arrow functions only (like someFunc: function () {..}).
  • If added a new recipe, then make sure to expose it inside the recipe folder present in the root of this repo. We also need to expose its types.

Remaining TODOs for this PR

  • Item1
  • Item2

@netlify
Copy link

netlify bot commented Oct 26, 2023

Deploy Preview for precious-marshmallow-968a81 canceled.

Name Link
🔨 Latest commit 3968f71
🔍 Latest deploy log https://app.netlify.com/sites/precious-marshmallow-968a81/deploys/6540d4373f89ed00084e03d1

@netlify
Copy link

netlify bot commented Oct 26, 2023

Deploy Preview for astounding-pegasus-21c111 failed.

Name Link
🔨 Latest commit 3968f71
🔍 Latest deploy log https://app.netlify.com/sites/astounding-pegasus-21c111/deploys/6540d437956eaf00084f813b

@@ -49,6 +50,9 @@ export default class SuperTokens {
telemetryEnabled: boolean;

constructor(config: TypeInput) {
if (config.debug) {
Copy link
Member

Choose a reason for hiding this comment

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

  • we also want it to work for with the env var like before (backwards compatibility)
  • Doing implicit if is not a good idea. Make it if (config.debug === true)

package.json Show resolved Hide resolved
lib/ts/supertokens.ts Outdated Show resolved Hide resolved
test/config.test.js Show resolved Hide resolved
@@ -48,7 +48,16 @@ export default class SuperTokens {

telemetryEnabled: boolean;

debugEnabled: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

this variable should not be required, and even if it is, it should be in the logger.ts file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was only used in the tests, removed it.

lib/ts/logger.ts Outdated
);
console.log();
}
debug(SUPERTOKENS_DEBUG_NAMESPACE)(
Copy link
Member

Choose a reason for hiding this comment

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

why aren't you checking for if (debug.enabled(SUPERTOKENS_DEBUG_NAMESPACE)) {?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We already call debug.enable() when initialising the logger, so ideally this should always return true. Added this check, just for safety.

@rishabhpoddar rishabhpoddar changed the base branch from master to 16.4 October 31, 2023 10:34
@rishabhpoddar rishabhpoddar merged commit 841c7b3 into 16.4 Oct 31, 2023
9 of 11 checks passed
@rishabhpoddar rishabhpoddar deleted the feat/use-flag-for-logging branch October 31, 2023 11:16
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