Fail over to console.log if lacking console method
This improves logger resiliency under older browsers.
This commit is contained in:
@@ -225,11 +225,9 @@ export var logger = {
|
||||
|
||||
// Can be overridden in the host environment
|
||||
log: function(level, message) {
|
||||
if (logger.level <= level) {
|
||||
if (typeof console !== 'undefined' && logger.level <= level) {
|
||||
var method = logger.methodMap[level];
|
||||
if (typeof console !== 'undefined' && console[method]) {
|
||||
console[method].call(console, message);
|
||||
}
|
||||
(console[method] || console.log).call(console, message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
+5
-1
@@ -276,7 +276,7 @@ describe('builtin helpers', function() {
|
||||
equals(3, levelArg);
|
||||
equals("whee", logArg);
|
||||
});
|
||||
it('should not output to info', function() {
|
||||
it('should output to info', function() {
|
||||
var string = "{{log blah}}";
|
||||
var hash = { blah: "whee" };
|
||||
|
||||
@@ -284,6 +284,10 @@ describe('builtin helpers', function() {
|
||||
equals("whee", log);
|
||||
called = true;
|
||||
};
|
||||
console.log = function(log) {
|
||||
equals("whee", log);
|
||||
called = true;
|
||||
};
|
||||
|
||||
shouldCompileTo(string, hash, "");
|
||||
equals(true, called);
|
||||
|
||||
Reference in New Issue
Block a user