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

Add logLevel as an SDK init option #279

Closed
EduardoSimon opened this issue Sep 3, 2024 · 0 comments · Fixed by #315
Closed

Add logLevel as an SDK init option #279

EduardoSimon opened this issue Sep 3, 2024 · 0 comments · Fixed by #315
Assignees
Labels
type: enhancement New feature or request

Comments

@EduardoSimon
Copy link

EduardoSimon commented Sep 3, 2024

Is your feature request related to a problem? Please describe.

Hi folks 👋🏼 ,
I am creating a small library wrapping the SDK to standardize its usage within my company. As we use a custom Otel collector, we need to disable the options validation by providing the skipOptionsValidation flag in the sdk instantiation. However, as a result a debug log is printed to the console. In the browser its not such a big deal, as the debug log level is disabled by default, nevertheless when running tests in node, the stdout gets cluttered with those debug messages.

image

Describe the solution you'd like

I was wondering if you would consider adding a logLevel flag to the sdk so we can set it to info or error when running in test mode. I've checked the source code, identifying the location in which a custom logger could be used. Let me know if you might accept PRs with it or how the contribution process works.

Describe the alternatives

For now I've found a workaround by monkey patching the global console object and disallowing any debug call.

const originalConsole = globalThis.console;

globalThis.console = {
  ...originalConsole,
  debug: () => {}
};

Note: We use the latest version of Node, that's why we use the globalThis object.

@EduardoSimon EduardoSimon added the type: enhancement New feature or request label Sep 3, 2024
@jairo-mendoza jairo-mendoza self-assigned this Oct 8, 2024
jairo-mendoza added a commit that referenced this issue Oct 15, 2024
<!--
Thank you for contributing to the project! 💜
Please see our [OSS process
document](https://github.com/honeycombio/home/blob/main/honeycomb-oss-lifecycle-and-practices.md#)
to get an idea of how we operate.
-->

## Which problem is this PR solving?

- Closes #279

## Short description of the changes

Users will now have the option to set a log level when initializing the
SDK. This log level controls the verbosity of logs outputted. The
current log levels includes DEBUG, INFO, WARN, and ERROR.

## How to verify that this has the expected result
- Unit tests have been added
- I tested locally by reproducing the issue and seeing if my changes
fixed the issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants