AppAuth-JS icon indicating copy to clipboard operation
AppAuth-JS copied to clipboard

Can logging be disabled?

Open pofallon opened this issue 6 years ago • 11 comments

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

pofallon avatar Aug 30 '18 00:08 pofallon

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

tikurahul avatar Aug 30 '18 23:08 tikurahul

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.

someone1 avatar Oct 11 '18 21:10 someone1

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

tikurahul avatar Oct 13 '18 15:10 tikurahul

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

uifox avatar Dec 07 '18 08:12 uifox

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.

tikurahul avatar Dec 07 '18 18:12 tikurahul

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

someone1 avatar Dec 07 '18 18:12 someone1

Yes. Will make sure I try that as well.

tikurahul avatar Dec 08 '18 17:12 tikurahul

Are there any updates on this ?

ArthurKnoep avatar Mar 02 '20 00:03 ArthurKnoep

Bump

KevinDanikowski avatar Sep 14 '20 20:09 KevinDanikowski

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.

aikoven avatar Sep 15 '20 09:09 aikoven