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

fix(browser): filter browser logging by level #2493

Merged
merged 1 commit into from Jan 14, 2017

Conversation

wesleycho
Copy link
Member

  • Do not log lower levels if browserConsoleLogOptions.level is set

This should address #2228.

type = type.toUpperCase()
if (browserConsoleLogOptions.level) {
var logPriority = constants.LOG_PRIORITIES.indexOf(browserConsoleLogOptions.level.toUpperCase())
if (constants.LOG_PRIORITIES[type] > logPriority) return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't constants.LOG_PRIORITIES[type] a string, rather than a number?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops...that was meant to be indexOf

- Do not log lower levels if `browserConsoleLogOptions.level` is set
@@ -14,6 +14,14 @@ exports.LOG_ERROR = 'ERROR'
exports.LOG_WARN = 'WARN'
exports.LOG_INFO = 'INFO'
exports.LOG_DEBUG = 'DEBUG'
exports.LOG_PRIORITIES = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you missed to add the 'LOG' level itself to constants.js,
exports.LOG_LOG = 'LOG'

exports.LOG_PRIORITIES = [
exports.LOG_DISABLE,
exports.LOG_ERROR,
exports.LOG_WARN,
exports.LOG_INFO,
exports.LOG_DEBUG,
exports.LOG_LOG
]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no LOG_LOG in this file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, but we need to add it.
LOG_LOG maps to 'console.log' function as well as LOG_DEBUG maps to 'console.debug'
Try your pull request with console.log and browserConsoleLogOptions.level = 'debug' and you will see that it doesn't work, cause
constants.LOG_PRIORITIES.indexOf(type)
will have -1 (not found)

@dignifiedquire dignifiedquire merged commit 35965d9 into karma-runner:master Jan 14, 2017
@dignifiedquire
Copy link
Member

Thank you :octocat:

@wesleycho wesleycho deleted the fix/browser-log branch May 4, 2017 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants