layouts.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. /* automatically generated by JSCoverage - do not edit */
  2. if (typeof _$jscoverage === 'undefined') _$jscoverage = {};
  3. if (! _$jscoverage['layouts.js']) {
  4. _$jscoverage['layouts.js'] = [];
  5. _$jscoverage['layouts.js'][1] = 0;
  6. _$jscoverage['layouts.js'][2] = 0;
  7. _$jscoverage['layouts.js'][8] = 0;
  8. _$jscoverage['layouts.js'][9] = 0;
  9. _$jscoverage['layouts.js'][10] = 0;
  10. _$jscoverage['layouts.js'][11] = 0;
  11. _$jscoverage['layouts.js'][13] = 0;
  12. _$jscoverage['layouts.js'][27] = 0;
  13. _$jscoverage['layouts.js'][28] = 0;
  14. _$jscoverage['layouts.js'][29] = 0;
  15. _$jscoverage['layouts.js'][30] = 0;
  16. _$jscoverage['layouts.js'][32] = 0;
  17. _$jscoverage['layouts.js'][37] = 0;
  18. _$jscoverage['layouts.js'][38] = 0;
  19. _$jscoverage['layouts.js'][39] = 0;
  20. _$jscoverage['layouts.js'][42] = 0;
  21. _$jscoverage['layouts.js'][61] = 0;
  22. _$jscoverage['layouts.js'][62] = 0;
  23. _$jscoverage['layouts.js'][64] = 0;
  24. _$jscoverage['layouts.js'][65] = 0;
  25. _$jscoverage['layouts.js'][70] = 0;
  26. _$jscoverage['layouts.js'][71] = 0;
  27. _$jscoverage['layouts.js'][74] = 0;
  28. _$jscoverage['layouts.js'][75] = 0;
  29. _$jscoverage['layouts.js'][84] = 0;
  30. _$jscoverage['layouts.js'][96] = 0;
  31. _$jscoverage['layouts.js'][97] = 0;
  32. _$jscoverage['layouts.js'][104] = 0;
  33. _$jscoverage['layouts.js'][105] = 0;
  34. _$jscoverage['layouts.js'][111] = 0;
  35. _$jscoverage['layouts.js'][112] = 0;
  36. _$jscoverage['layouts.js'][144] = 0;
  37. _$jscoverage['layouts.js'][145] = 0;
  38. _$jscoverage['layouts.js'][146] = 0;
  39. _$jscoverage['layouts.js'][148] = 0;
  40. _$jscoverage['layouts.js'][150] = 0;
  41. _$jscoverage['layouts.js'][151] = 0;
  42. _$jscoverage['layouts.js'][152] = 0;
  43. _$jscoverage['layouts.js'][153] = 0;
  44. _$jscoverage['layouts.js'][154] = 0;
  45. _$jscoverage['layouts.js'][155] = 0;
  46. _$jscoverage['layouts.js'][156] = 0;
  47. _$jscoverage['layouts.js'][159] = 0;
  48. _$jscoverage['layouts.js'][162] = 0;
  49. _$jscoverage['layouts.js'][163] = 0;
  50. _$jscoverage['layouts.js'][164] = 0;
  51. _$jscoverage['layouts.js'][165] = 0;
  52. _$jscoverage['layouts.js'][167] = 0;
  53. _$jscoverage['layouts.js'][168] = 0;
  54. _$jscoverage['layouts.js'][169] = 0;
  55. _$jscoverage['layouts.js'][170] = 0;
  56. _$jscoverage['layouts.js'][171] = 0;
  57. _$jscoverage['layouts.js'][172] = 0;
  58. _$jscoverage['layouts.js'][176] = 0;
  59. _$jscoverage['layouts.js'][179] = 0;
  60. _$jscoverage['layouts.js'][180] = 0;
  61. _$jscoverage['layouts.js'][183] = 0;
  62. _$jscoverage['layouts.js'][184] = 0;
  63. _$jscoverage['layouts.js'][187] = 0;
  64. _$jscoverage['layouts.js'][188] = 0;
  65. _$jscoverage['layouts.js'][191] = 0;
  66. _$jscoverage['layouts.js'][192] = 0;
  67. _$jscoverage['layouts.js'][195] = 0;
  68. _$jscoverage['layouts.js'][196] = 0;
  69. _$jscoverage['layouts.js'][199] = 0;
  70. _$jscoverage['layouts.js'][200] = 0;
  71. _$jscoverage['layouts.js'][203] = 0;
  72. _$jscoverage['layouts.js'][204] = 0;
  73. _$jscoverage['layouts.js'][207] = 0;
  74. _$jscoverage['layouts.js'][208] = 0;
  75. _$jscoverage['layouts.js'][209] = 0;
  76. _$jscoverage['layouts.js'][210] = 0;
  77. _$jscoverage['layouts.js'][212] = 0;
  78. _$jscoverage['layouts.js'][215] = 0;
  79. _$jscoverage['layouts.js'][218] = 0;
  80. _$jscoverage['layouts.js'][231] = 0;
  81. _$jscoverage['layouts.js'][232] = 0;
  82. _$jscoverage['layouts.js'][235] = 0;
  83. _$jscoverage['layouts.js'][236] = 0;
  84. _$jscoverage['layouts.js'][237] = 0;
  85. _$jscoverage['layouts.js'][238] = 0;
  86. _$jscoverage['layouts.js'][239] = 0;
  87. _$jscoverage['layouts.js'][242] = 0;
  88. _$jscoverage['layouts.js'][245] = 0;
  89. _$jscoverage['layouts.js'][246] = 0;
  90. _$jscoverage['layouts.js'][247] = 0;
  91. _$jscoverage['layouts.js'][248] = 0;
  92. _$jscoverage['layouts.js'][249] = 0;
  93. _$jscoverage['layouts.js'][251] = 0;
  94. _$jscoverage['layouts.js'][252] = 0;
  95. _$jscoverage['layouts.js'][255] = 0;
  96. _$jscoverage['layouts.js'][257] = 0;
  97. _$jscoverage['layouts.js'][258] = 0;
  98. _$jscoverage['layouts.js'][262] = 0;
  99. _$jscoverage['layouts.js'][265] = 0;
  100. _$jscoverage['layouts.js'][266] = 0;
  101. _$jscoverage['layouts.js'][267] = 0;
  102. _$jscoverage['layouts.js'][268] = 0;
  103. _$jscoverage['layouts.js'][270] = 0;
  104. _$jscoverage['layouts.js'][271] = 0;
  105. _$jscoverage['layouts.js'][272] = 0;
  106. _$jscoverage['layouts.js'][273] = 0;
  107. _$jscoverage['layouts.js'][274] = 0;
  108. _$jscoverage['layouts.js'][275] = 0;
  109. _$jscoverage['layouts.js'][276] = 0;
  110. _$jscoverage['layouts.js'][279] = 0;
  111. _$jscoverage['layouts.js'][280] = 0;
  112. _$jscoverage['layouts.js'][284] = 0;
  113. _$jscoverage['layouts.js'][290] = 0;
  114. _$jscoverage['layouts.js'][291] = 0;
  115. _$jscoverage['layouts.js'][292] = 0;
  116. _$jscoverage['layouts.js'][294] = 0;
  117. _$jscoverage['layouts.js'][296] = 0;
  118. _$jscoverage['layouts.js'][301] = 0;
  119. _$jscoverage['layouts.js'][308] = 0;
  120. }
  121. _$jscoverage['layouts.js'][1]++;
  122. "use strict";
  123. _$jscoverage['layouts.js'][2]++;
  124. var dateFormat = require("./date_format"), os = require("os"), eol = os.EOL || "\n", util = require("util"), replacementRegExp = /%[sdj]/g, layoutMakers = {"messagePassThrough": (function () {
  125. _$jscoverage['layouts.js'][8]++;
  126. return messagePassThroughLayout;
  127. }), "basic": (function () {
  128. _$jscoverage['layouts.js'][9]++;
  129. return basicLayout;
  130. }), "colored": (function () {
  131. _$jscoverage['layouts.js'][10]++;
  132. return colouredLayout;
  133. }), "coloured": (function () {
  134. _$jscoverage['layouts.js'][11]++;
  135. return colouredLayout;
  136. }), "pattern": (function (config) {
  137. _$jscoverage['layouts.js'][13]++;
  138. return patternLayout(config && config.pattern, config && config.tokens);
  139. })}, colours = {ALL: "grey", TRACE: "blue", DEBUG: "cyan", INFO: "green", WARN: "yellow", ERROR: "red", FATAL: "magenta", OFF: "grey"};
  140. _$jscoverage['layouts.js'][27]++;
  141. function wrapErrorsWithInspect(items) {
  142. _$jscoverage['layouts.js'][28]++;
  143. return items.map((function (item) {
  144. _$jscoverage['layouts.js'][29]++;
  145. if ((item instanceof Error) && item.stack) {
  146. _$jscoverage['layouts.js'][30]++;
  147. return ({inspect: (function () {
  148. _$jscoverage['layouts.js'][30]++;
  149. return util.format(item) + "\n" + item.stack;
  150. })});
  151. }
  152. else {
  153. _$jscoverage['layouts.js'][32]++;
  154. return item;
  155. }
  156. }));
  157. }
  158. _$jscoverage['layouts.js'][37]++;
  159. function formatLogData(logData) {
  160. _$jscoverage['layouts.js'][38]++;
  161. var data = Array.isArray(logData)? logData: Array.prototype.slice.call(arguments);
  162. _$jscoverage['layouts.js'][39]++;
  163. return util.format.apply(util, wrapErrorsWithInspect(data));
  164. }
  165. _$jscoverage['layouts.js'][42]++;
  166. var styles = {"bold": [1, 22], "italic": [3, 23], "underline": [4, 24], "inverse": [7, 27], "white": [37, 39], "grey": [90, 39], "black": [90, 39], "blue": [34, 39], "cyan": [36, 39], "green": [32, 39], "magenta": [35, 39], "red": [31, 39], "yellow": [33, 39]};
  167. _$jscoverage['layouts.js'][61]++;
  168. function colorizeStart(style) {
  169. _$jscoverage['layouts.js'][62]++;
  170. return style? "\u001b[" + styles[style][0] + "m": "";
  171. }
  172. _$jscoverage['layouts.js'][64]++;
  173. function colorizeEnd(style) {
  174. _$jscoverage['layouts.js'][65]++;
  175. return style? "\u001b[" + styles[style][1] + "m": "";
  176. }
  177. _$jscoverage['layouts.js'][70]++;
  178. function colorize(str, style) {
  179. _$jscoverage['layouts.js'][71]++;
  180. return colorizeStart(style) + str + colorizeEnd(style);
  181. }
  182. _$jscoverage['layouts.js'][74]++;
  183. function timestampLevelAndCategory(loggingEvent, colour) {
  184. _$jscoverage['layouts.js'][75]++;
  185. var output = colorize(formatLogData("[%s] [%s] %s - ", dateFormat.asString(loggingEvent.startTime), loggingEvent.level, loggingEvent.categoryName), colour);
  186. _$jscoverage['layouts.js'][84]++;
  187. return output;
  188. }
  189. _$jscoverage['layouts.js'][96]++;
  190. function basicLayout(loggingEvent) {
  191. _$jscoverage['layouts.js'][97]++;
  192. return timestampLevelAndCategory(loggingEvent) + formatLogData(loggingEvent.data);
  193. }
  194. _$jscoverage['layouts.js'][104]++;
  195. function colouredLayout(loggingEvent) {
  196. _$jscoverage['layouts.js'][105]++;
  197. return timestampLevelAndCategory(loggingEvent, colours[loggingEvent.level.toString()]) + formatLogData(loggingEvent.data);
  198. }
  199. _$jscoverage['layouts.js'][111]++;
  200. function messagePassThroughLayout(loggingEvent) {
  201. _$jscoverage['layouts.js'][112]++;
  202. return formatLogData(loggingEvent.data);
  203. }
  204. _$jscoverage['layouts.js'][144]++;
  205. function patternLayout(pattern, tokens) {
  206. _$jscoverage['layouts.js'][145]++;
  207. var TTCC_CONVERSION_PATTERN = "%r %p %c - %m%n";
  208. _$jscoverage['layouts.js'][146]++;
  209. var regex = /%(-?[0-9]+)?(\.?[0-9]+)?([\[\]cdmnprx%])(\{([^\}]+)\})?|([^%]+)/;
  210. _$jscoverage['layouts.js'][148]++;
  211. pattern = pattern || TTCC_CONVERSION_PATTERN;
  212. _$jscoverage['layouts.js'][150]++;
  213. function categoryName(loggingEvent, specifier) {
  214. _$jscoverage['layouts.js'][151]++;
  215. var loggerName = loggingEvent.categoryName;
  216. _$jscoverage['layouts.js'][152]++;
  217. if (specifier) {
  218. _$jscoverage['layouts.js'][153]++;
  219. var precision = parseInt(specifier, 10);
  220. _$jscoverage['layouts.js'][154]++;
  221. var loggerNameBits = loggerName.split(".");
  222. _$jscoverage['layouts.js'][155]++;
  223. if (precision < loggerNameBits.length) {
  224. _$jscoverage['layouts.js'][156]++;
  225. loggerName = loggerNameBits.slice(loggerNameBits.length - precision).join(".");
  226. }
  227. }
  228. _$jscoverage['layouts.js'][159]++;
  229. return loggerName;
  230. }
  231. _$jscoverage['layouts.js'][162]++;
  232. function formatAsDate(loggingEvent, specifier) {
  233. _$jscoverage['layouts.js'][163]++;
  234. var format = dateFormat.ISO8601_FORMAT;
  235. _$jscoverage['layouts.js'][164]++;
  236. if (specifier) {
  237. _$jscoverage['layouts.js'][165]++;
  238. format = specifier;
  239. _$jscoverage['layouts.js'][167]++;
  240. if (format == "ISO8601") {
  241. _$jscoverage['layouts.js'][168]++;
  242. format = dateFormat.ISO8601_FORMAT;
  243. }
  244. else {
  245. _$jscoverage['layouts.js'][169]++;
  246. if (format == "ABSOLUTE") {
  247. _$jscoverage['layouts.js'][170]++;
  248. format = dateFormat.ABSOLUTETIME_FORMAT;
  249. }
  250. else {
  251. _$jscoverage['layouts.js'][171]++;
  252. if (format == "DATE") {
  253. _$jscoverage['layouts.js'][172]++;
  254. format = dateFormat.DATETIME_FORMAT;
  255. }
  256. }
  257. }
  258. }
  259. _$jscoverage['layouts.js'][176]++;
  260. return dateFormat.asString(format, loggingEvent.startTime);
  261. }
  262. _$jscoverage['layouts.js'][179]++;
  263. function formatMessage(loggingEvent) {
  264. _$jscoverage['layouts.js'][180]++;
  265. return formatLogData(loggingEvent.data);
  266. }
  267. _$jscoverage['layouts.js'][183]++;
  268. function endOfLine() {
  269. _$jscoverage['layouts.js'][184]++;
  270. return eol;
  271. }
  272. _$jscoverage['layouts.js'][187]++;
  273. function logLevel(loggingEvent) {
  274. _$jscoverage['layouts.js'][188]++;
  275. return loggingEvent.level.toString();
  276. }
  277. _$jscoverage['layouts.js'][191]++;
  278. function startTime(loggingEvent) {
  279. _$jscoverage['layouts.js'][192]++;
  280. return "" + loggingEvent.startTime.toLocaleTimeString();
  281. }
  282. _$jscoverage['layouts.js'][195]++;
  283. function startColour(loggingEvent) {
  284. _$jscoverage['layouts.js'][196]++;
  285. return colorizeStart(colours[loggingEvent.level.toString()]);
  286. }
  287. _$jscoverage['layouts.js'][199]++;
  288. function endColour(loggingEvent) {
  289. _$jscoverage['layouts.js'][200]++;
  290. return colorizeEnd(colours[loggingEvent.level.toString()]);
  291. }
  292. _$jscoverage['layouts.js'][203]++;
  293. function percent() {
  294. _$jscoverage['layouts.js'][204]++;
  295. return "%";
  296. }
  297. _$jscoverage['layouts.js'][207]++;
  298. function userDefined(loggingEvent, specifier) {
  299. _$jscoverage['layouts.js'][208]++;
  300. if (typeof tokens[specifier] !== "undefined") {
  301. _$jscoverage['layouts.js'][209]++;
  302. if (typeof tokens[specifier] === "function") {
  303. _$jscoverage['layouts.js'][210]++;
  304. return tokens[specifier](loggingEvent);
  305. }
  306. else {
  307. _$jscoverage['layouts.js'][212]++;
  308. return tokens[specifier];
  309. }
  310. }
  311. _$jscoverage['layouts.js'][215]++;
  312. return null;
  313. }
  314. _$jscoverage['layouts.js'][218]++;
  315. var replacers = {"c": categoryName, "d": formatAsDate, "m": formatMessage, "n": endOfLine, "p": logLevel, "r": startTime, "[": startColour, "]": endColour, "%": percent, "x": userDefined};
  316. _$jscoverage['layouts.js'][231]++;
  317. function replaceToken(conversionCharacter, loggingEvent, specifier) {
  318. _$jscoverage['layouts.js'][232]++;
  319. return replacers[conversionCharacter](loggingEvent, specifier);
  320. }
  321. _$jscoverage['layouts.js'][235]++;
  322. function truncate(truncation, toTruncate) {
  323. _$jscoverage['layouts.js'][236]++;
  324. var len;
  325. _$jscoverage['layouts.js'][237]++;
  326. if (truncation) {
  327. _$jscoverage['layouts.js'][238]++;
  328. len = parseInt(truncation.substr(1), 10);
  329. _$jscoverage['layouts.js'][239]++;
  330. return toTruncate.substring(0, len);
  331. }
  332. _$jscoverage['layouts.js'][242]++;
  333. return toTruncate;
  334. }
  335. _$jscoverage['layouts.js'][245]++;
  336. function pad(padding, toPad) {
  337. _$jscoverage['layouts.js'][246]++;
  338. var len;
  339. _$jscoverage['layouts.js'][247]++;
  340. if (padding) {
  341. _$jscoverage['layouts.js'][248]++;
  342. if (padding.charAt(0) == "-") {
  343. _$jscoverage['layouts.js'][249]++;
  344. len = parseInt(padding.substr(1), 10);
  345. _$jscoverage['layouts.js'][251]++;
  346. while (toPad.length < len) {
  347. _$jscoverage['layouts.js'][252]++;
  348. toPad += " ";
  349. }
  350. }
  351. else {
  352. _$jscoverage['layouts.js'][255]++;
  353. len = parseInt(padding, 10);
  354. _$jscoverage['layouts.js'][257]++;
  355. while (toPad.length < len) {
  356. _$jscoverage['layouts.js'][258]++;
  357. toPad = " " + toPad;
  358. }
  359. }
  360. }
  361. _$jscoverage['layouts.js'][262]++;
  362. return toPad;
  363. }
  364. _$jscoverage['layouts.js'][265]++;
  365. return (function (loggingEvent) {
  366. _$jscoverage['layouts.js'][266]++;
  367. var formattedString = "";
  368. _$jscoverage['layouts.js'][267]++;
  369. var result;
  370. _$jscoverage['layouts.js'][268]++;
  371. var searchString = pattern;
  372. _$jscoverage['layouts.js'][270]++;
  373. while ((result = regex.exec(searchString))) {
  374. _$jscoverage['layouts.js'][271]++;
  375. var matchedString = result[0];
  376. _$jscoverage['layouts.js'][272]++;
  377. var padding = result[1];
  378. _$jscoverage['layouts.js'][273]++;
  379. var truncation = result[2];
  380. _$jscoverage['layouts.js'][274]++;
  381. var conversionCharacter = result[3];
  382. _$jscoverage['layouts.js'][275]++;
  383. var specifier = result[5];
  384. _$jscoverage['layouts.js'][276]++;
  385. var text = result[6];
  386. _$jscoverage['layouts.js'][279]++;
  387. if (text) {
  388. _$jscoverage['layouts.js'][280]++;
  389. formattedString += "" + text;
  390. }
  391. else {
  392. _$jscoverage['layouts.js'][284]++;
  393. var replacement = replaceToken(conversionCharacter, loggingEvent, specifier) || matchedString;
  394. _$jscoverage['layouts.js'][290]++;
  395. replacement = truncate(truncation, replacement);
  396. _$jscoverage['layouts.js'][291]++;
  397. replacement = pad(padding, replacement);
  398. _$jscoverage['layouts.js'][292]++;
  399. formattedString += replacement;
  400. }
  401. _$jscoverage['layouts.js'][294]++;
  402. searchString = searchString.substr(result.index + result[0].length);
  403. }
  404. _$jscoverage['layouts.js'][296]++;
  405. return formattedString;
  406. });
  407. }
  408. _$jscoverage['layouts.js'][301]++;
  409. module.exports = {basicLayout: basicLayout, messagePassThroughLayout: messagePassThroughLayout, patternLayout: patternLayout, colouredLayout: colouredLayout, coloredLayout: colouredLayout, layout: (function (name, config) {
  410. _$jscoverage['layouts.js'][308]++;
  411. return layoutMakers[name] && layoutMakers[name](config);
  412. })};
  413. _$jscoverage['layouts.js'].source = ["\"use strict\";","var dateFormat = require('./date_format')",", os = require('os')",", eol = os.EOL || '\\n'",", util = require('util')",", replacementRegExp = /%[sdj]/g",", layoutMakers = {"," \"messagePassThrough\": function() { return messagePassThroughLayout; }, "," \"basic\": function() { return basicLayout; }, "," \"colored\": function() { return colouredLayout; }, "," \"coloured\": function() { return colouredLayout; }, "," \"pattern\": function (config) {"," return patternLayout(config &amp;&amp; config.pattern, config &amp;&amp; config.tokens);","\t}","}",", colours = {"," ALL: \"grey\", "," TRACE: \"blue\", "," DEBUG: \"cyan\", "," INFO: \"green\", "," WARN: \"yellow\", "," ERROR: \"red\", "," FATAL: \"magenta\", "," OFF: \"grey\"","};","","function wrapErrorsWithInspect(items) {"," return items.map(function(item) {"," if ((item instanceof Error) &amp;&amp; item.stack) {"," return { inspect: function() { return util.format(item) + '\\n' + item.stack; } };"," } else {"," return item;"," }"," });","}","","function formatLogData(logData) {"," var data = Array.isArray(logData) ? logData : Array.prototype.slice.call(arguments);"," return util.format.apply(util, wrapErrorsWithInspect(data));","}","","var styles = {"," //styles"," 'bold' : [1, 22],"," 'italic' : [3, 23],"," 'underline' : [4, 24],"," 'inverse' : [7, 27],"," //grayscale"," 'white' : [37, 39],"," 'grey' : [90, 39],"," 'black' : [90, 39],"," //colors"," 'blue' : [34, 39],"," 'cyan' : [36, 39],"," 'green' : [32, 39],"," 'magenta' : [35, 39],"," 'red' : [31, 39],"," 'yellow' : [33, 39]","};","","function colorizeStart(style) {"," return style ? '\\x1B[' + styles[style][0] + 'm' : '';","}","function colorizeEnd(style) {"," return style ? '\\x1B[' + styles[style][1] + 'm' : '';","}","/**"," * Taken from masylum's fork (https://github.com/masylum/log4js-node)"," */","function colorize (str, style) {"," return colorizeStart(style) + str + colorizeEnd(style);","}","","function timestampLevelAndCategory(loggingEvent, colour) {"," var output = colorize("," formatLogData("," '[%s] [%s] %s - '"," , dateFormat.asString(loggingEvent.startTime)"," , loggingEvent.level"," , loggingEvent.categoryName"," )"," , colour"," );"," return output;","}","","/**"," * BasicLayout is a simple layout for storing the logs. The logs are stored"," * in following format:"," * &lt;pre&gt;"," * [startTime] [logLevel] categoryName - message\\n"," * &lt;/pre&gt;"," *"," * @author Stephan Strittmatter"," */","function basicLayout (loggingEvent) {"," return timestampLevelAndCategory(loggingEvent) + formatLogData(loggingEvent.data);","}","","/**"," * colouredLayout - taken from masylum's fork."," * same as basicLayout, but with colours."," */","function colouredLayout (loggingEvent) {"," return timestampLevelAndCategory("," loggingEvent,"," colours[loggingEvent.level.toString()]"," ) + formatLogData(loggingEvent.data);","}","","function messagePassThroughLayout (loggingEvent) {"," return formatLogData(loggingEvent.data);","}","","/**"," * PatternLayout"," * Format for specifiers is %[padding].[truncation][field]{[format]}"," * e.g. %5.10p - left pad the log level by 5 characters, up to a max of 10"," * Fields can be any of:"," * - %r time in toLocaleTimeString format"," * - %p log level"," * - %c log category"," * - %m log data"," * - %d date in various formats"," * - %% %"," * - %n newline"," * - %x{&lt;tokenname&gt;} add dynamic tokens to your log. Tokens are specified in the tokens parameter"," * You can use %[ and %] to define a colored block."," *"," * Tokens are specified as simple key:value objects. "," * The key represents the token name whereas the value can be a string or function"," * which is called to extract the value to put in the log message. If token is not"," * found, it doesn't replace the field."," *"," * A sample token would be: { \"pid\" : function() { return process.pid; } }"," *"," * Takes a pattern string, array of tokens and returns a layout function."," * @param {String} Log format pattern String"," * @param {object} map object of different tokens"," * @return {Function}"," * @author Stephan Strittmatter"," * @author Jan Schmidle"," */","function patternLayout (pattern, tokens) {"," var TTCC_CONVERSION_PATTERN = \"%r %p %c - %m%n\";"," var regex = /%(-?[0-9]+)?(\\.?[0-9]+)?([\\[\\]cdmnprx%])(\\{([^\\}]+)\\})?|([^%]+)/;"," "," pattern = pattern || TTCC_CONVERSION_PATTERN;",""," function categoryName(loggingEvent, specifier) {"," var loggerName = loggingEvent.categoryName;"," if (specifier) {"," var precision = parseInt(specifier, 10);"," var loggerNameBits = loggerName.split(\".\");"," if (precision &lt; loggerNameBits.length) {"," loggerName = loggerNameBits.slice(loggerNameBits.length - precision).join(\".\");"," }"," }"," return loggerName;"," }",""," function formatAsDate(loggingEvent, specifier) {"," var format = dateFormat.ISO8601_FORMAT;"," if (specifier) {"," format = specifier;"," // Pick up special cases"," if (format == \"ISO8601\") {"," format = dateFormat.ISO8601_FORMAT;"," } else if (format == \"ABSOLUTE\") {"," format = dateFormat.ABSOLUTETIME_FORMAT;"," } else if (format == \"DATE\") {"," format = dateFormat.DATETIME_FORMAT;"," }"," }"," // Format the date"," return dateFormat.asString(format, loggingEvent.startTime);"," }",""," function formatMessage(loggingEvent) {"," return formatLogData(loggingEvent.data);"," }"," "," function endOfLine() {"," return eol;"," }",""," function logLevel(loggingEvent) {"," return loggingEvent.level.toString();"," }",""," function startTime(loggingEvent) {"," return \"\" + loggingEvent.startTime.toLocaleTimeString();"," }",""," function startColour(loggingEvent) {"," return colorizeStart(colours[loggingEvent.level.toString()]);"," }",""," function endColour(loggingEvent) {"," return colorizeEnd(colours[loggingEvent.level.toString()]);"," }",""," function percent() {"," return '%';"," }",""," function userDefined(loggingEvent, specifier) {"," if (typeof(tokens[specifier]) !== 'undefined') {"," if (typeof(tokens[specifier]) === 'function') {"," return tokens[specifier](loggingEvent);"," } else {"," return tokens[specifier];"," }"," }"," return null;"," }",""," var replacers = {"," 'c': categoryName,"," 'd': formatAsDate,"," 'm': formatMessage,"," 'n': endOfLine,"," 'p': logLevel,"," 'r': startTime,"," '[': startColour,"," ']': endColour,"," '%': percent,"," 'x': userDefined"," };",""," function replaceToken(conversionCharacter, loggingEvent, specifier) {"," return replacers[conversionCharacter](loggingEvent, specifier);"," }",""," function truncate(truncation, toTruncate) {"," var len;"," if (truncation) {"," len = parseInt(truncation.substr(1), 10);"," return toTruncate.substring(0, len);"," }",""," return toTruncate;"," }",""," function pad(padding, toPad) {"," var len;"," if (padding) {"," if (padding.charAt(0) == \"-\") {"," len = parseInt(padding.substr(1), 10);"," // Right pad with spaces"," while (toPad.length &lt; len) {"," toPad += \" \";"," }"," } else {"," len = parseInt(padding, 10);"," // Left pad with spaces"," while (toPad.length &lt; len) {"," toPad = \" \" + toPad;"," }"," }"," }"," return toPad;"," }"," "," return function(loggingEvent) {"," var formattedString = \"\";"," var result;"," var searchString = pattern;"," "," while ((result = regex.exec(searchString))) {"," var matchedString = result[0];"," var padding = result[1];"," var truncation = result[2];"," var conversionCharacter = result[3];"," var specifier = result[5];"," var text = result[6];"," "," // Check if the pattern matched was just normal text"," if (text) {"," formattedString += \"\" + text;"," } else {"," // Create a raw replacement string based on the conversion"," // character and specifier"," var replacement = "," replaceToken(conversionCharacter, loggingEvent, specifier) || "," matchedString;",""," // Format the replacement according to any padding or"," // truncation specified"," replacement = truncate(truncation, replacement);"," replacement = pad(padding, replacement);"," formattedString += replacement;"," }"," searchString = searchString.substr(result.index + result[0].length);"," }"," return formattedString;"," };","","}","","module.exports = {"," basicLayout: basicLayout, "," messagePassThroughLayout: messagePassThroughLayout, "," patternLayout: patternLayout, "," colouredLayout: colouredLayout, "," coloredLayout: colouredLayout, "," layout: function(name, config) {"," return layoutMakers[name] &amp;&amp; layoutMakers[name](config);"," }","};"];