Bugsnag-js: Add configuration option to disable console debugging

Created on 11 Jan 2018  路  9Comments  路  Source: bugsnag/bugsnag-js

Expected behavior

To be able to configure the console debugging verbosity

Observed behavior

In the console, [bugsnag] Loaded is printed during every app load. Consequently the console output in our end to end testing suite gets filled with those messages.

Steps to reproduce

Load an application with bugsnag in the browswer, and notice in the console that [bugsnag] Loaded! is printed there

Version

4.0.3

Additional information

This seems to be the line in question.

This is really just an issue for us in our testing environment, so being able to configure the verbosity level, or suppressing that one line would be great. Thanks!

released

Most helpful comment

Hey everyone, thanks for your patience! This is now published in v4.6.0.

You can now switch logging off entirely via

bugsnag({ apiKey: '...', logger: null })

Since you can do everything you need with either logger: null or logger: customLogger we figured a logLevel option was surplus.

All 9 comments

You can configure the verbosity in the developer tools. In Chrome, the default values do not list console.debug (verbose) messages.

image

For testing you can configure the client with a logger that doesn't log anything:

const noop = Function.prototype
const testLogger = ['debug', 'info', 'log', 'error']
  .reduce((logger, method) => ({...logger, [method]: noop}), {})

client.logger(testLogger)

@langri-sha thank you for your response. i know that you can do that in the browser, but our primary use case is on our CI server, where you dont have that.

I might be misunderstanding the second suggestion, but in trying to use that, the client is already initialized, so its already logged the Loaded! message by the time we try and set the logger.

It seems reasonable to add a logLevel config option that you can set to null (off) or debug, warn, info, error.

I'll schedule this.

@bengourley It seems to me that setting a custom logger already allows a lot of control over logging behavior and the problem is that bugsnag-js logs a message before it allows a logger to be set.

Would it make sense to allow a custom logger as a config option?

Would the logLevel option create a logger that ignored the appropriate messages, or would it determine what is passed to the custom logger if one is set?

+1

It'd really be nice if output could be muted. Having [bugsnag] Loaded! in the console for a production app isn't ideal.

@bengourley 馃檶

Hey everyone, thanks for your patience! This is now published in v4.6.0.

You can now switch logging off entirely via

bugsnag({ apiKey: '...', logger: null })

Since you can do everything you need with either logger: null or logger: customLogger we figured a logLevel option was surplus.

I have v6.4.3 but even with logger set to null (which I don't really want to have to write conditions for as a workaround in my CI/test environment), I still get the following:
Screen Shot 2020-06-20 at 5 46 52 PM

I don't understand why when I pro-actively set that I don't want bugsnag involved in my test stage, it feels the need to tell me every time that I've done that. It seems the most common use case that in dev and test I don't need a bug tracking tool. I don't want to write custom loggers or conditional code to not be nagged. Can we add a nag: false setting or something?

Hey @toxaq, that sounds like a bug. Setting logger: null should essentially make Bugsnag silent (other than fatal misconfigurations). I've had a quick look with the latest version and I can't reproduce. Can you provide a repro case? Feel free to open a new issue or write in to [email protected].

Was this page helpful?
0 / 5 - 0 ratings