Commit 375ccb64 authored by CompileNix's avatar CompileNix

re-apply code format

parent 9d631b57
class Config {
constructor() {
this.filesToWatch = [
'test.txt',
'test1.txt'
"test.txt",
"test1.txt"
];
// nginx
this.defaultMessageTemplateFilter = /^\[((\d{1,2}\/\w{3}\/\d{4}):(\d{2}:\d{2}:\d{2}) ([+-]\d{4}))\] status:(\d{3}) request_time:(\d{1,}.\d{3}) upstream_response_time:((\d{1,}.\d{3})|-) bytes_sent:(\d{1,}) client_ip:(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b|(:{0,2}[\da-f]{1,4}){1,8}) domain:([\w.-]*) request:"((\w{3,8}) (\/[\w-.,_~:<>\\/[\]%@!$'()*+;?=&#]*) HTTP\/(\d\.\d))" referer:"([\w-.,_~:<>\\/[\]%@!$'()*+;?=&#]*)" user_agent:"([\w-.,_~: \/[\]%@!$'()*+;?=&#]*)"$/;
......@@ -49,21 +49,21 @@ class Config {
// };
this.enableEmail = false;
this.smtpUsername = 'smtp login username';
this.smtpPassword = 'password';
this.smtpHost = 'your.email.server';
this.smtpUsername = "smtp login username";
this.smtpPassword = "password";
this.smtpHost = "your.email.server";
this.smtpPort = 25;
this.smtps = false;
this.mailfrom = 'foo@bar.local';
this.mailto = 'foo@bar.local';
this.subjectPrefix = 'access_log mailer: ';
this.mailfrom = "foo@bar.local";
this.mailto = "foo@bar.local";
this.subjectPrefix = "access_log mailer: ";
this.enableSlack = false;
this.slackWebHookUri = 'https://hooks.slack.com/services/xxxxxx/xxxxxx/xxxxxx';
this.slackChannel = '#general';
this.slackUsername = 'webserver-access_log-bot';
this.slackWebHookUri = "https://hooks.slack.com/services/xxxxxx/xxxxxx/xxxxxx";
this.slackChannel = "#general";
this.slackUsername = "webserver-access_log-bot";
this.botName = 'web-access_log2email';
this.botName = "web-access_log2email";
this.botIcon = "https://compilenix.org/cdn/Compilenix.png";
this.debug = true;
......@@ -110,6 +110,6 @@ class Config {
}
];
}
};
}
module.exports = new Config();
'use-strict';
"use-strict";
const fs = require("fs-extra");
const nodemailer = require('nodemailer');
const nodemailer = require("nodemailer");
const config = require("./Config.js");
const Tail = require('tail').Tail;
const Slack = require('slack-node');
const Tail = require("tail").Tail;
const Slack = require("slack-node");
let transporter;
let slack = new Slack();
......@@ -36,14 +36,14 @@ async function notificationQueueWorker() {
if (match === null) match = message.message;
const oldSubject = message.expression.subject;
if (typeof (message.expression.subject) !== 'function') {
var oldSubjectValue = '';
if (typeof (message.expression.subject) !== "function") {
var oldSubjectValue = "";
if (message.expression.subject && message.expression.subject.toString) oldSubjectValue = message.expression.subject.toString();
message.expression.subject = () => oldSubjectValue;
}
const oldTemplate = message.expression.template;
if (typeof (message.expression.template) !== 'function') {
if (typeof (message.expression.template) !== "function") {
var oldTemplateValue = `\`${message.message}\``;
if (message.expression.template && message.expression.template.toString) oldTemplateValue = message.expression.template.toString();
message.expression.template = () => oldTemplateValue;
......@@ -102,7 +102,7 @@ async function sendMail(mailOptions) {
if (config.debug) console.log(error);
reject(error);
} else {
if (config.debug) console.log('Email sent: ' + info.response);
if (config.debug) console.log("Email sent: " + info.response);
resolve(info);
}
});
......@@ -111,7 +111,7 @@ async function sendMail(mailOptions) {
async function setupTail( /** @type {string[]} */ filesToWatch) {
if (!config.expressions || config.expressions.length < 1) {
console.error('no expressions defined in config!');
console.error("no expressions defined in config!");
process.exit(1);
}
......@@ -128,11 +128,11 @@ async function setupTail( /** @type {string[]} */ filesToWatch) {
follow: true
});
tail.on('line', ( /** @type {string} */ data) => {
tail.on("line", ( /** @type {string} */ data) => {
filterLog(data);
});
tail.on('error', error => {
tail.on("error", error => {
console.log(`Watcher ERROR (${fileName}): `, error);
});
......@@ -155,7 +155,7 @@ function setupSmtp() {
from: config.mailfrom,
to: config.mailto,
subject: `${config.subjectPrefix} -`,
text: ''
text: ""
};
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment