debug improved

This commit is contained in:
Wolfgang Hottgenroth
2017-08-28 12:39:53 +02:00
parent 9356a81fd1
commit 5b909f5a7a
8 changed files with 55 additions and 47 deletions

26
dist/log.js vendored
View File

@ -2,6 +2,8 @@
Object.defineProperty(exports, "__esModule", { value: true });
const chalk = require("chalk");
const moment = require("moment");
const config = require("./config");
const nodemailer = require("nodemailer");
var Level;
(function (Level) {
Level[Level["All"] = 0] = "All";
@ -28,6 +30,30 @@ function setLevel(value) {
}
}
exports.setLevel = setLevel;
function sendAlarmMail(message) {
let transport = nodemailer.createTransport({
host: config.dict.smtpHost,
port: config.dict.smtpPort,
secure: false,
tls: {
rejectUnauthorized: false
}
});
let mail = {
from: config.dict.smtpSender,
to: config.dict.smtpReceiver,
subject: "Alarm from Dispatcher",
text: message
};
transport.sendMail(mail)
.then((v) => {
info(`Alarm mail sent, ${message}, ${v.response}`);
})
.catch((reason) => {
error(`Failure when sending alarm mail: ${message}, ${reason}`);
});
}
exports.sendAlarmMail = sendAlarmMail;
function info(message) {
if (level < Level.NoDebugNoInfo) {
console.log(`${timestamp()} ${chalk.bold.cyan('[ II ]')} ${message}`);