-
Notifications
You must be signed in to change notification settings - Fork 250
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
Logging module #1405
Logging module #1405
Conversation
@@ -0,0 +1,78 @@ | |||
define(['core/js/adapt'], function(Adapt) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you put some whitespace into this file?
should be spaces 4 indentation, line breaks between function definitions etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 4 for indentation conflicts with the 2 stated in the style guide which is linked to on the the Contributing-code page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignore the referenced/copied standard, it hasn't been formalized yet. It should say "spaces 4" indentation, no tabs, etc.
src/core/js/logging.js
Outdated
this.debug('Logging config loaded'); | ||
this.trigger('log:ready'); | ||
}, | ||
debug: function(msg, data) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These functions need their parameters to behaviour more like the console.log
function.
essentially each argument forms part of the output string.
fatal: function() {
this._log('fatal', [].array.slice.call(arguments, 0)));
},
_log: function(level, datas) {
if (!this._config._isEnabled) {
return;
}
if (this._levels[level] < this._levels[this._config._level]) {
return;
}
if (this._config._console) {
var log = [level.toUpperCase() + ':'];
datas && log.push.apply(log, datas);
console.log.apply(console, log);
}
// Allow error reporting plugins to hook and report to logging systems
this.trigger('log:' + level, datas);
}
Allowing:
Adapt.log.fatal("this", "is", "a", "fatal", "error");
//FATAL: this is a fatal error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do.
…ve, adjusted log functions arguments
Should be ready to review again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beautiful ta. Much easier to read. It needs to work in ie8 though, so you'll need to use underscore bind and supply arguments to your splice calls, I think.
Also, only if you fancy doing it. You can return early twice in the initialize function, rather than a double nested if. Invert the expressions and return, flattening the code.
IE8 has been EOL for a while now and as far as I'm aware is not supported on any current MS OSs. |
For ethical reasons I don't make changes to specifically support IE8, the browser is EOL and no longer receiving security updates, it's usage is negligent. |
Fair enough. I'll see if someone else can take over. |
functionality added on #1425 thanks for doing this @ryanrolds |
Adds logging module discussed in #1390.