first posts

This commit is contained in:
2018-05-10 22:23:31 +02:00
parent 0686e02b75
commit 88b2cf4212
11 changed files with 234 additions and 62 deletions

26
dist/log.js vendored
View File

@ -1,8 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const moment = require("moment");
const config = require("./config");
const nodemailer = require("nodemailer");
var Level;
(function (Level) {
Level[Level["All"] = 0] = "All";
@ -29,30 +27,6 @@ function setLevel(value) {
}
}
exports.setLevel = setLevel;
function sendAlarmMail(subject, 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: subject,
text: message
};
transport.sendMail(mail)
.then((v) => {
info(`Mail sent, ${subject}, ${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()} [ II ] ${message}`);