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

Can logging be disabled? #75

Open
pofallon opened this issue Aug 30, 2018 · 11 comments
Open

Can logging be disabled? #75

pofallon opened this issue Aug 30, 2018 · 11 comments
Assignees

Comments

@pofallon
Copy link

Expected Behavior

Ideally it would not log steps to the console by default, or logging could be disabled. I see the IS_LOG value in the "flags" module, but it's defined as a const and I'm not sure how I can affect that value at run time in a way to prevent logging. Thanks!

Describe the problem

Actual Behavior

Currently the library prints messages to the console as it's executing, such as:
Checking to see if there is an authorization response to be delivered. (here)

Steps to reproduce the behavior

Invoking the library functions as demonstrated in the Electron sample application

Environment

  • AppAuth-JS version: 0.3.5
  • AppAuth-JS Environment (Node, Browser (UserAgent), ...): node 10.9
@tikurahul tikurahul self-assigned this Aug 30, 2018
@tikurahul
Copy link
Collaborator

I will add some documentation on how this can be done.

@someone1
Copy link
Contributor

someone1 commented Oct 11, 2018

I remember asking this a while back as well - the code can't be optimized away (due to the const IS_LOG value) with default build configs such as with webpack4.

Even in a production build where the logging may be discarded, the code is still in the optimized bundles since it can't be detected as unused/dead code by UglifyJS2. I think when I asked before you mentioned there was a way with the "Closure compiler" but I'm still not clear on that.

Other optimization questions (sorry, I don't mean to hijack this issue) - is this package sideEffect free? Can we add the setting to the package.json? Will the target build be able to be tree shaken properly and such (doesn't the tsc compiler target ES3 by default)? I like the idea of hybrid deployments with ES2015+ as described in this article - it's a little beyond me so excuse me if this project is already setup for it but it would be nice to see this package updated as such.

@tikurahul
Copy link
Collaborator

My apologies. I lost track of this. I am going to document this. Stay tuned.

@uifox
Copy link

uifox commented Dec 7, 2018

Hey @tikurahul
Any update on how logging could be disabled? Thanks.

@tikurahul
Copy link
Collaborator

I have not started on this one yet. TBH.
Will try a few things with closure compiler flags. As @someone1 said the const on the flag is probably going to be problematic, and I am going to fix it to make it a configurable value at build time.

@someone1
Copy link
Contributor

someone1 commented Dec 7, 2018

Whatever method is used, can you ensure it also works for those of us using Webpack + UglifyJS?

@tikurahul
Copy link
Collaborator

Yes. Will make sure I try that as well.

@ArthurKnoep
Copy link

Are there any updates on this ?

@KevinDanikowski
Copy link

Bump

@aikoven
Copy link

aikoven commented Sep 15, 2020

For now one can manually edit node_modules/@openid/appauth/built/flags.js file to set IS_LOG = false and then use patch-package to persist these changes.

@relu91
Copy link

relu91 commented Jul 1, 2024

If you don't care too much about bundle optimization (e.g., you are working on Node cli application), the correct way (with the current codebase) to disable logging should be:

const { setFlag } = require('@openid/appauth/built/flags')
// ...
setFlag('IS_LOG', false);

@tikurahul let me know if I missed something.

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

No branches or pull requests

8 participants