/* automatically generated by JSCoverage - do not edit */
if (typeof _$jscoverage === 'undefined') _$jscoverage = {};
if (! _$jscoverage['logging/appenders/jsonAppender.js']) {
  _$jscoverage['logging/appenders/jsonAppender.js'] = [];
  _$jscoverage['logging/appenders/jsonAppender.js'][1] = 0;
  _$jscoverage['logging/appenders/jsonAppender.js'][52] = 0;
  _$jscoverage['logging/appenders/jsonAppender.js'][56] = 0;
  _$jscoverage['logging/appenders/jsonAppender.js'][57] = 0;
  _$jscoverage['logging/appenders/jsonAppender.js'][58] = 0;
  _$jscoverage['logging/appenders/jsonAppender.js'][59] = 0;
  _$jscoverage['logging/appenders/jsonAppender.js'][60] = 0;
  _$jscoverage['logging/appenders/jsonAppender.js'][61] = 0;
  _$jscoverage['logging/appenders/jsonAppender.js'][62] = 0;
  _$jscoverage['logging/appenders/jsonAppender.js'][63] = 0;
  _$jscoverage['logging/appenders/jsonAppender.js'][65] = 0;
  _$jscoverage['logging/appenders/jsonAppender.js'][66] = 0;
  _$jscoverage['logging/appenders/jsonAppender.js'][70] = 0;
  _$jscoverage['logging/appenders/jsonAppender.js'][71] = 0;
  _$jscoverage['logging/appenders/jsonAppender.js'][72] = 0;
  _$jscoverage['logging/appenders/jsonAppender.js'][73] = 0;
  _$jscoverage['logging/appenders/jsonAppender.js'][74] = 0;
  _$jscoverage['logging/appenders/jsonAppender.js'][80] = 0;
  _$jscoverage['logging/appenders/jsonAppender.js'][81] = 0;
}
_$jscoverage['logging/appenders/jsonAppender.js'][1]++;
var define = require("../../define.js").define, base = require("../../base"), string = base.string, escape = base.regexp.escapeString, FileAppender = require("./fileAppender"), format = string.format, Level = require("../level"), fs = require("fs");
_$jscoverage['logging/appenders/jsonAppender.js'][52]++;
exports = module.exports = define(FileAppender, {instance: {constructor: (function (options) {
  _$jscoverage['logging/appenders/jsonAppender.js'][56]++;
  options = options || {};
  _$jscoverage['logging/appenders/jsonAppender.js'][57]++;
  this.name = options.name || "JSONAppender";
  _$jscoverage['logging/appenders/jsonAppender.js'][58]++;
  this.__count = 0;
  _$jscoverage['logging/appenders/jsonAppender.js'][59]++;
  this.__file = options.file || "./log.json";
  _$jscoverage['logging/appenders/jsonAppender.js'][60]++;
  this.__encoding = options.encoding || "utf8";
  _$jscoverage['logging/appenders/jsonAppender.js'][61]++;
  this.__writeStream = options.writeStream || fs.createWriteStream(this.__file, {flags: "w", encoding: this.__encoding});
  _$jscoverage['logging/appenders/jsonAppender.js'][62]++;
  this.__writeStream.write("[\n");
  _$jscoverage['logging/appenders/jsonAppender.js'][63]++;
  this.__level = options.level;
  _$jscoverage['logging/appenders/jsonAppender.js'][65]++;
  this.__pattern = "{\"timestamp\" : \"{timeStamp}\", \"level\" : \"{levelName}\", \"name\" : \"{name}\", \"message\" :  \"{message}\"}";
  _$jscoverage['logging/appenders/jsonAppender.js'][66]++;
  process.addListener("exit", base.hitch(this, "__onExit"));
}), append: (function (event) {
  _$jscoverage['logging/appenders/jsonAppender.js'][70]++;
  if (this._canAppend(event)) {
    _$jscoverage['logging/appenders/jsonAppender.js'][71]++;
    event.message = event.message.replace(/\n+/g, "\\n");
    _$jscoverage['logging/appenders/jsonAppender.js'][72]++;
    var message = (this.__count? ",\n": "\n") + format(this.__pattern, event);
    _$jscoverage['logging/appenders/jsonAppender.js'][73]++;
    this.__writeStream.write(message);
    _$jscoverage['logging/appenders/jsonAppender.js'][74]++;
    this.__count++;
  }
}), __onExit: (function () {
  _$jscoverage['logging/appenders/jsonAppender.js'][80]++;
  this.__writeStream.write("]");
  _$jscoverage['logging/appenders/jsonAppender.js'][81]++;
  this["super"](arguments);
})}});
_$jscoverage['logging/appenders/jsonAppender.js'].source = ["var define = require(\"../../define.js\").define,","\t\tbase = require(\"../../base\"),","\t\tstring = base.string,","\t\tescape = base.regexp.escapeString,","\t\tFileAppender = require(\"./fileAppender\"),","\t\tformat = string.format,","\t\tLevel = require(\"../level\"),","\t\tfs = require(\"fs\");","","","/**"," * @class Appends messages to a file in JSON format. The messages are logged to an array in a JSON file"," * &lt;b&gt;The file is always overwritten&lt;/b&gt;"," *"," * &lt;pre class=\"code\"&gt;"," * //example log.json"," * ["," *    {"," *      \"timestamp\" : \"Wed Jun 08 2011 11:16:20 GMT-0500 (CDT)\","," *      \"level\" : \"INFO\","," *      \"name\" : \"comb\","," *      \"message\" :  \"INFO MESSAGE!!!!\""," *    }"," *  ]"," *"," *&lt;/pre&gt;"," *"," * @name JSONAppender"," * @augments comb.logging.appenders.FileAppender"," * @memberOf comb.logging.appenders"," *"," * @param {Object} [options] options to assign to this Appender"," * @param {String} [options.name=\"appender\"] the name of this Appender. If you want two of the same type of appender"," *                                           on a logger it must have a different name."," * @param {String} [options.pattern=\"{\"timestamp\" : \"{timeStamp}\", \"level\" : \"{levelName}\", \"name\" : \"{name}\", \"message\" :  \"{message}\"}\"]"," *  &lt;p&gt;Available Options for formatting see {@link comb.string.format} for formatting options&lt;/p&gt;"," *  &lt;ul&gt;"," *      &lt;li&gt;timeStamp - the timestamp of the event being logged&lt;/li&gt;"," *      &lt;li&gt;level - the {@link comb.logging.Level} of the event&lt;/li&gt;"," *      &lt;li&gt;levelName - the name of the level being logged&lt;/li&gt;"," *      &lt;li&gt;name - the name of the logger logging the event&lt;/li&gt;"," *      &lt;li&gt;message - the message being logged&lt;/li&gt;"," * &lt;/ul&gt;"," * @param {comb.logging.Level|String} [options.level=comb.logging.Level.INFO] the logging level of this appender"," *      &lt;p&gt;&lt;b&gt;Note:&lt;/b&gt; the level can be different from the logger in the case that you want a particular logger"," *      to only log particular event of a level. For example an appender that only logs errors. BEWARE that if the"," *      appenders level is lower than the logger is will not recieve any messages.&lt;/p&gt;"," *"," * @param {String} [options.file=\"./log.json\"] the file to log events to."," * @param {String} [options.encoding=\"utf8\"] the encoding of the file."," */","exports = module.exports = define(FileAppender, {","\t\t\tinstance : {","","\t\t\t\tconstructor : function(options) {","\t\t\t\t\toptions = options || {};","\t\t\t\t\tthis.name = options.name || \"JSONAppender\";","\t\t\t\t\tthis.__count = 0;","\t\t\t\t\tthis.__file = options.file || \"./log.json\";","\t\t\t\t\tthis.__encoding = options.encoding || \"utf8\";","\t\t\t\t\tthis.__writeStream = options.writeStream || fs.createWriteStream(this.__file, { flags: \"w\", encoding: this.__encoding});","\t\t\t\t\tthis.__writeStream.write(\"[\\n\");","\t\t\t\t\tthis.__level = options.level;","\t\t\t\t\t//explicit overwrite of patter","\t\t\t\t\tthis.__pattern = '{\"timestamp\" : \"{timeStamp}\", \"level\" : \"{levelName}\", \"name\" : \"{name}\", \"message\" :  \"{message}\"}';","\t\t\t\t\tprocess.addListener(\"exit\", base.hitch(this, \"__onExit\"));","\t\t\t\t},","","\t\t\t\tappend : function(event) {","\t\t\t\t\tif (this._canAppend(event)) {","\t\t\t\t\t\tevent.message = event.message.replace(/\\n+/g, \"\\\\n\");","\t\t\t\t\t\tvar message = (this.__count ? \",\\n\" : \"\\n\") + format(this.__pattern, event);","                        this.__writeStream.write(message);","\t\t\t\t\t\tthis.__count++;","\t\t\t\t\t}","\t\t\t\t},","","","\t\t\t\t__onExit : function() {","\t\t\t\t\tthis.__writeStream.write(\"]\");","\t\t\t\t\tthis.super(arguments);","\t\t\t\t}","\t\t\t}","\t\t});"];
