Function.prototype.apply: Arguments list has wrong type on BrowserConsoleAppender
Brought to you by:
timdown
BrowserConsoleAppender contains the lines:
if (typeof console[consoleMethodName].apply == "function") { console[consoleMethodName].apply(console, getFormattedMessage(false)); }
however, appender.getLayout().formatWithException mostly returns a simple string.
In which case a log statement will result in
Uncaught TypeError: Function.prototype.apply: Arguments list has wrong type at Object.BrowserConsoleAppender.append (http://log4javascript.org/js/log4javascript.js:148:84) at Object.Appender.doAppend (http://log4javascript.org/js/log4javascript.js:81:437) at Object.callAppenders (http://log4javascript.org/js/log4javascript.js:64:282) at Object.log (http://log4javascript.org/js/log4javascript.js:64:82) at Object.Logger.debug (http://log4javascript.org/js/log4javascript.js:68:92) at <anonymous>:2:174
(Beacuse the second parameter of "apply" is a string and not an array.)
This is easily reproduced by calling
(function(l){ var appender = new log4javascript.BrowserConsoleAppender(), layout = new log4javascript.SimpleLayout(); appender.setLayout(layout); l.addAppender(appender); l.debug("Hello, World!"); })(log4javascript.getLogger("x"));
on one of the demo-pages.
Oops. I introduced this in fixing another issue in BrowserConsoleAppender a couple of weeks ago.
Thanks for this.
Fixed in 1.4.13.