Menu

#14 Function.prototype.apply: Arguments list has wrong type on BrowserConsoleAppender

closed
nobody
None
5
2015-05-23
2015-05-22
No

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.

Discussion

  • Tim Down

    Tim Down - 2015-05-23

    Oops. I introduced this in fixing another issue in BrowserConsoleAppender a couple of weeks ago.

    Thanks for this.

     
  • Tim Down

    Tim Down - 2015-05-23
    • status: open --> closed
     
  • Tim Down

    Tim Down - 2015-05-23

    Fixed in 1.4.13.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.