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

[BUG] Can't set log level #265

Open
1 task done
AntonRatnick opened this issue Jun 19, 2024 · 4 comments
Open
1 task done

[BUG] Can't set log level #265

AntonRatnick opened this issue Jun 19, 2024 · 4 comments

Comments

@AntonRatnick
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

SDK Version

3.1.1

Current Behavior

Setting log level to Error, don't reduce amount of warnings and info logs in console

Expected Behavior

If log level == Error no info or warning logs appear in console.

Steps To Reproduce

  1. Changing log level to Error, the way described in the documentation not changing console output
  2. Passing log level as part of config to createInstance also not working

React Framework

No response

Browsers impacted

No response

Link

  1. https://github.com/optimizely/react-sdk/blob/master/src/logger.tsx#L19 Here we create logger instance and pass only prefix.
  2. https://github.com/optimizely/javascript-sdk/blob/4909efb74335b754592ddf6e8415047fc0bf3e7b/lib/modules/logging/logger.ts#L99
    If I am not mistaken this is the logger we creating, without any arguments beside the prefix.
  3. import { logger } from './logger';

    Here we import created logger, and use it.
  4. The logger instance created for React SDK is not exported, so changing log level on created instance also not possible.

Logs

No response

Severity

No response

Workaround/Solution

No response

Recent Change

No response

Conflicts

No response

@AntonRatnick AntonRatnick added bug Something isn't working needs-triage labels Jun 19, 2024
@alexparish
Copy link

alexparish commented Jun 24, 2024

I was just in the process of creating a bug for this exact scenario. Luckily saw this one first!

It's frustrating that, as a consumer, I cannot change the log level of the react-sdk internal logger as it is causing a lot of unnecessary log noise for my services in certain scenarios.

@Bundas
Copy link

Bundas commented Jul 11, 2024

I was poking around and it seems like the easiest solution is to export the instance of logger in src/logger.tsx called logHandler. Once it is exported, we can access it at a constructor of OptimizelyReactSDKClient in src/client.ts and set a proper log level based on the config there. I tested it locally and it works like a charm. Unfortunately I can't create a PR at this time, so if anybody has a capacity...

@junaed-optimizely
Copy link
Contributor

This definitely requires some attention. There are some inconsistencies that I can confirm. I have created an internal ticket FSSDK-10554 for further investigation.

@junaed-optimizely
Copy link
Contributor

@AntonRatnick, there is a patch release v3.2.2 out with the fix. Could you please check and confirm?

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

No branches or pull requests

4 participants