question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No way to check if init has already been called or to catch/ignore resulting console error.

See original GitHub issue

Please let me know if I’m missing something but:

  • There doesn’t appear to be a way to check if datadogLogs.init() has already been called, and console.error() is called if it had already been initialized. However, since we’re sending our console errors to datadog, this leads to our logs getting spammed by these error messages that we don’t care about. Ideally, there would be something on the datadogLogs API that we could check before calling init to see if it has already been called.

  • There’s no good workaround at the moment for suppressing these console errors, because they’re using console.error() rather than throw - presumably this is because you don’t want to halt execution, which is understandable - however, it’d be nice in this case if there was a way to configure the logger to filter out certain console errors. If such functionality already exists, that would be something that would be helpful to highlight in the documentation.

Thanks!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
mquentincommented, Mar 19, 2020

Hey, a new option has been added to the datadogLogs.init() : silentMultipleInit. If you turn this optional boolean on, the multiple init will still be aborted but will not trigger any console.error.

2reactions
bcaudancommented, Mar 17, 2020

Thanks for the details, it makes sense.

Would an init option be more convenient to suppress the already initialized error?

something like:

datadogLogs.init({
  ...
  silentMultipleInit: true,
  ...
})
Read more comments on GitHub >

github_iconTop Results From Across the Web

Jest: mocking console.error - tests fails - Stack Overflow
I ran into a similar problem, just needed to cache the original method const original = console.error beforeEach(() => { console.error ...
Read more >
Assert console.error call times when mocking it - Malcolm Kee
A common case that I encounter is testing error boundary in React. The console.error is trying to be helpful, however when the error...
Read more >
Untitled
Defaults to 'undefined' if a container filter is not specified by the configuration. ... [config.failure] The function to call upon error of the...
Read more >
Groovy Language Documentation
In Groovy, bitwise operators have the particularity of being overloadable, meaning that you can define the behavior of those operators for any kind...
Read more >
https://bugs.eclipse.org/bugs/attachment.cgi?id=260656
isWrite()) { /** * If reference is writeable, this is the tree being ... fromTDZ) { var _this7 = this; // If this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found