/* automatically generated by JSCoverage - do not edit */
if (typeof _$jscoverage === 'undefined') _$jscoverage = {};
if (! _$jscoverage['appenders/smtp.js']) {
  _$jscoverage['appenders/smtp.js'] = [];
  _$jscoverage['appenders/smtp.js'][1] = 0;
  _$jscoverage['appenders/smtp.js'][2] = 0;
  _$jscoverage['appenders/smtp.js'][16] = 0;
  _$jscoverage['appenders/smtp.js'][17] = 0;
  _$jscoverage['appenders/smtp.js'][18] = 0;
  _$jscoverage['appenders/smtp.js'][19] = 0;
  _$jscoverage['appenders/smtp.js'][21] = 0;
  _$jscoverage['appenders/smtp.js'][22] = 0;
  _$jscoverage['appenders/smtp.js'][24] = 0;
  _$jscoverage['appenders/smtp.js'][25] = 0;
  _$jscoverage['appenders/smtp.js'][27] = 0;
  _$jscoverage['appenders/smtp.js'][28] = 0;
  _$jscoverage['appenders/smtp.js'][29] = 0;
  _$jscoverage['appenders/smtp.js'][30] = 0;
  _$jscoverage['appenders/smtp.js'][31] = 0;
  _$jscoverage['appenders/smtp.js'][34] = 0;
  _$jscoverage['appenders/smtp.js'][40] = 0;
  _$jscoverage['appenders/smtp.js'][41] = 0;
  _$jscoverage['appenders/smtp.js'][43] = 0;
  _$jscoverage['appenders/smtp.js'][44] = 0;
  _$jscoverage['appenders/smtp.js'][45] = 0;
  _$jscoverage['appenders/smtp.js'][47] = 0;
  _$jscoverage['appenders/smtp.js'][52] = 0;
  _$jscoverage['appenders/smtp.js'][53] = 0;
  _$jscoverage['appenders/smtp.js'][54] = 0;
  _$jscoverage['appenders/smtp.js'][55] = 0;
  _$jscoverage['appenders/smtp.js'][56] = 0;
  _$jscoverage['appenders/smtp.js'][61] = 0;
  _$jscoverage['appenders/smtp.js'][62] = 0;
  _$jscoverage['appenders/smtp.js'][63] = 0;
  _$jscoverage['appenders/smtp.js'][64] = 0;
  _$jscoverage['appenders/smtp.js'][66] = 0;
  _$jscoverage['appenders/smtp.js'][71] = 0;
  _$jscoverage['appenders/smtp.js'][72] = 0;
  _$jscoverage['appenders/smtp.js'][73] = 0;
  _$jscoverage['appenders/smtp.js'][74] = 0;
  _$jscoverage['appenders/smtp.js'][76] = 0;
  _$jscoverage['appenders/smtp.js'][79] = 0;
  _$jscoverage['appenders/smtp.js'][80] = 0;
  _$jscoverage['appenders/smtp.js'][81] = 0;
}
_$jscoverage['appenders/smtp.js'][1]++;
"use strict";
_$jscoverage['appenders/smtp.js'][2]++;
var layouts = require("../layouts"), mailer = require("nodemailer"), os = require("os");
_$jscoverage['appenders/smtp.js'][16]++;
function smtpAppender(config, layout) {
  _$jscoverage['appenders/smtp.js'][17]++;
  layout = layout || layouts.basicLayout;
  _$jscoverage['appenders/smtp.js'][18]++;
  var subjectLayout = layouts.messagePassThroughLayout;
  _$jscoverage['appenders/smtp.js'][19]++;
  var sendInterval = config.sendInterval * 1000 || 0;
  _$jscoverage['appenders/smtp.js'][21]++;
  var logEventBuffer = [];
  _$jscoverage['appenders/smtp.js'][22]++;
  var sendTimer;
  _$jscoverage['appenders/smtp.js'][24]++;
  function sendBuffer() {
    _$jscoverage['appenders/smtp.js'][25]++;
    if (logEventBuffer.length > 0) {
      _$jscoverage['appenders/smtp.js'][27]++;
      var transport = mailer.createTransport(config.transport, config[config.transport]);
      _$jscoverage['appenders/smtp.js'][28]++;
      var firstEvent = logEventBuffer[0];
      _$jscoverage['appenders/smtp.js'][29]++;
      var body = "";
      _$jscoverage['appenders/smtp.js'][30]++;
      while (logEventBuffer.length > 0) {
        _$jscoverage['appenders/smtp.js'][31]++;
        body += layout(logEventBuffer.shift()) + "\n";
}
      _$jscoverage['appenders/smtp.js'][34]++;
      var msg = {to: config.recipients, subject: config.subject || subjectLayout(firstEvent), text: body, headers: {"Hostname": os.hostname()}};
      _$jscoverage['appenders/smtp.js'][40]++;
      if (config.sender) {
        _$jscoverage['appenders/smtp.js'][41]++;
        msg.from = config.sender;
      }
      _$jscoverage['appenders/smtp.js'][43]++;
      transport.sendMail(msg, (function (error, success) {
  _$jscoverage['appenders/smtp.js'][44]++;
  if (error) {
    _$jscoverage['appenders/smtp.js'][45]++;
    console.error("log4js.smtpAppender - Error happened", error);
  }
  _$jscoverage['appenders/smtp.js'][47]++;
  transport.close();
}));
    }
}
  _$jscoverage['appenders/smtp.js'][52]++;
  function scheduleSend() {
    _$jscoverage['appenders/smtp.js'][53]++;
    if (! sendTimer) {
      _$jscoverage['appenders/smtp.js'][54]++;
      sendTimer = setTimeout((function () {
  _$jscoverage['appenders/smtp.js'][55]++;
  sendTimer = null;
  _$jscoverage['appenders/smtp.js'][56]++;
  sendBuffer();
}), sendInterval);
    }
}
  _$jscoverage['appenders/smtp.js'][61]++;
  return (function (loggingEvent) {
  _$jscoverage['appenders/smtp.js'][62]++;
  logEventBuffer.push(loggingEvent);
  _$jscoverage['appenders/smtp.js'][63]++;
  if (sendInterval > 0) {
    _$jscoverage['appenders/smtp.js'][64]++;
    scheduleSend();
  }
  else {
    _$jscoverage['appenders/smtp.js'][66]++;
    sendBuffer();
  }
});
}
_$jscoverage['appenders/smtp.js'][71]++;
function configure(config) {
  _$jscoverage['appenders/smtp.js'][72]++;
  var layout;
  _$jscoverage['appenders/smtp.js'][73]++;
  if (config.layout) {
    _$jscoverage['appenders/smtp.js'][74]++;
    layout = layouts.layout(config.layout.type, config.layout);
  }
  _$jscoverage['appenders/smtp.js'][76]++;
  return smtpAppender(config, layout);
}
_$jscoverage['appenders/smtp.js'][79]++;
exports.name = "smtp";
_$jscoverage['appenders/smtp.js'][80]++;
exports.appender = smtpAppender;
_$jscoverage['appenders/smtp.js'][81]++;
exports.configure = configure;
_$jscoverage['appenders/smtp.js'].source = ["\"use strict\";","var layouts = require(\"../layouts\")",", mailer = require(\"nodemailer\")",", os = require('os');","","/**","* SMTP Appender. Sends logging events using SMTP protocol. ","* It can either send an email on each event or group several ","* logging events gathered during specified interval.","*","* @param config appender configuration data","*    config.sendInterval time between log emails (in seconds), if 0","*    then every event sends an email","* @param layout a function that takes a logevent and returns a string (defaults to basicLayout).","*/","function smtpAppender(config, layout) {","\tlayout = layout || layouts.basicLayout;","\tvar subjectLayout = layouts.messagePassThroughLayout;","\tvar sendInterval = config.sendInterval*1000 || 0;","\t","\tvar logEventBuffer = [];","\tvar sendTimer;","\t","\tfunction sendBuffer() {","    if (logEventBuffer.length &gt; 0) {","\t\t","      var transport = mailer.createTransport(config.transport, config[config.transport]);","      var firstEvent = logEventBuffer[0];","      var body = \"\";","      while (logEventBuffer.length &gt; 0) {","        body += layout(logEventBuffer.shift()) + \"\\n\";","      }","","      var msg = {","        to: config.recipients,","        subject: config.subject || subjectLayout(firstEvent),","        text: body,","        headers: { \"Hostname\": os.hostname() }","      };","      if (config.sender) {","        msg.from = config.sender;","      }","      transport.sendMail(msg, function(error, success) {","        if (error) {","          console.error(\"log4js.smtpAppender - Error happened\", error);","        }","        transport.close();","      });","    }","\t}","\t","\tfunction scheduleSend() {","\t\tif (!sendTimer) {","\t\t\tsendTimer = setTimeout(function() {","\t\t\t\tsendTimer = null; ","\t\t\t\tsendBuffer();","\t\t\t}, sendInterval);","    }","\t}","\t","\treturn function(loggingEvent) {","\t\tlogEventBuffer.push(loggingEvent);","\t\tif (sendInterval &gt; 0) {","\t\t\tscheduleSend();","\t\t} else {","\t\t\tsendBuffer();","    }","\t};","}","","function configure(config) {","\tvar layout;","\tif (config.layout) {","\t\tlayout = layouts.layout(config.layout.type, config.layout);","\t}","\treturn smtpAppender(config, layout);","}","","exports.name = \"smtp\";","exports.appender = smtpAppender;","exports.configure = configure;",""];
