This is another helpful example aiming towards Log4 type functionality in JavaScript but still not deserving of Log4 branding. This article points out but one strategy for logging. True Log4 type functionality provides greater abstraction and reduced coupling by defining separate classes for Configuration, Filtering, Appending(output types), Formatting, and Context/Client management.
I would love to see Apache end the willi nilli proliferation of the Log4 branding in the JavaScript space by starting an actual Log4JavaScript project (or maybe more appropriately Log4ECMAScript) so that the ideas being proposed can be turned into a thoughtful concrete implementation.
For example, this code relies on console proliferation in the pages. Using Configuration and an Appender, the console might be instantiated dynamically and in serveral different ways. (dynamic div in current doc, new window write, new window with div,etc.) If we start to use the model already well defined by Log4, we will be able to plug in new implementations and improvements without having to rip and replace our pages and libraries. |