debug improved
This commit is contained in:
26
dist/log.js
vendored
26
dist/log.js
vendored
@ -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}`);
|
||||
|
Reference in New Issue
Block a user