Skip to content

Instantly share code, notes, and snippets.

@leoroos
leoroos / log4javascript_uncompressed.js
Created August 23, 2012 21:07
Addition of file location and line number output for a log statement of log4javascript. The addition is made in the Patternlayout.format function.
PatternLayout.prototype.format = function(loggingEvent) {
var regex = /%(-?[0-9]+)?(\.?[0-9]+)?([acdflmMnpr%])(\{([^\}]+)\})?|([^%]+)/;
var formattedString = "";
var result;
var searchString = this.pattern;
// Cannot use regex global flag since it doesn't work with exec in IE5
while ((result = regex.exec(searchString))) {
var matchedString = result[0];
var padding = result[1];