-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.js
More file actions
37 lines (33 loc) · 784 Bytes
/
Copy pathfunctions.js
File metadata and controls
37 lines (33 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const fs = require('fs');
module.exports = {
writeToLog: function(message) {
let line = getTimestamp() + " " + message + "\r\n";
fs.appendFile('log.txt', line, function (err) {
if (err) throw err;
console.log('Saved!');
});
},
getRulesList: function() {
let fullText = fs.readFileSync('rules.txt', 'UTF-8');
let rulesList = fullText.split('\r\n');
return rulesList;
}
}
function getTimestamp() {
//[dd/mm/yyyy - uu:mm:ss]
let date = new Date();
let msg = "[";
msg += date.getDate();
msg += "/";
msg += date.getMonth() + 1;
msg += "/";
msg += date.getFullYear();
msg += " - ";
msg += date.getHours();
msg += ":";
msg += date.getMinutes();
msg += ":";
msg += date.getSeconds();
msg += "]";
return msg;
};