No way to check if init has already been called or to catch/ignore resulting console error.
See original GitHub issuePlease 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, andconsole.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 callinginit
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 thanthrow
- 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:
- Created 4 years ago
- Reactions:2
- Comments:8 (1 by maintainers)
Top GitHub Comments
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 anyconsole.error
.Thanks for the details, it makes sense.
Would an init option be more convenient to suppress the
already initialized
error?something like: