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.

browserConsoleLogOptions does not filter console by level

See original GitHub issue

Expected behavior

I expect that if browserConsoleLogOptions.level === 'error', then any instance of console.log, console.debug or console.warn will not appear in my terminal.

Actual behavior

Instances of console.debug are still shown in my console, despite the following in my Karma configuration:

    browserConsoleLogOptions: {
      level: 'error',
      format: '%b %T: %m',
      terminal: true
    },

Specifically, console.debug('hello there!'); results in DEBUG: 'hello there!' being printed when I run tests.

Note that switching browserConsoleLogOptions.terminal to false correctly silences all console output.

Enviroment Details

Karma 1.1.0 with Webpack 2 through Babel 6 on macOS 10.11.5 with npm 3.8.8 and node v5.11.0. Please see package.json for full requirements.

Steps to reproduce the behaviour

  1. Clone the example repo found at https://github.com/jambonsw/webpack2-karma-logging-error-mve
  2. Install the packages with npm install
  3. Run tests with npm test

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
vigrecocommented, Aug 19, 2016

It seems that browserConsoleLogOptions.level is only taken into account for log files. There’s no filter for reporters. I’d like to help out with this one.

Also, I noticed that the current log levels are: ['log', 'error', 'warn', 'info', 'debug'] Since log has an higher level than error, console.log messages are always printed also if browserConsoleLogOptions.level is set to 'error'. @dignifiedquire is this a wanted behaviour?

0reactions
IgorAufrichtcommented, Mar 14, 2017

This change made the LOG level messages the lowest priority, which I think should not be the case based on the comment by @dignifiedquire above:

This should be changed to what was described in the original report. Moving log down between warn and info.

See #2602.

Read more comments on GitHub >

github_iconTop Results From Across the Web

console.log not working on any karma project - Stack Overflow
You can configure browserConsoleLogOptions in your karma conf file to specify what messages should appear on your terminal output. Set the level property...
Read more >
Run karma-ci script from karma rake task and set ... - GitLab
Ah, nevermind I was looking at browserConsoleLogOptions ... the one that corresponds to this CLI argument is logLevel which does not default to...
Read more >
Console log levels is disabled - Google Groups
Since Chrome updated to 68.0.3440.106, I cannot change console log levels. The drop down box is disabled and grey: Screenshot from 2018-09-05 09-46-16.png....
Read more >
filter-console - npm
Start using filter-console in your project by running `npm i filter-console`. There are 8 other projects in the npm registry using ...
Read more >
can't bind to 'mat-dialog-close' since it isn't a known property of ...
LOG_DISABLE, browserConsoleLogOptions: { level: 'disable', terminal: false },. But no matter what I do, my console output looks like this (sample) :
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