-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLog.js
28 lines (23 loc) · 962 Bytes
/
Log.js
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
/**
* @author Korentin Massif
* @version 0.1
*
* @file Creating log file to trace website management
*/
const fs = require('fs');
class Logger {
/** @private Path to the log file*/ #path = "DB.log";
/** @private Options used to display the date*/ #options = {year: 'numeric', month: 'numeric', day: 'numeric', hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: false, timeZone: 'Europe/Paris'};
constructor() {}
/**
* Function used to log into the file
* @param {string} table Name of the table you are working in
* @param {string} userStatus Status of the message (ERROR, INFO, SUCCES ...)
* @param {string} message
*/
log(table, userStatus, message) {
const userLog = `${table}\t| ${new Date().toLocaleDateString('fr-FR', this.#options)}\t| ${userStatus}\t| ${message}\n`;
fs.appendFile(this.#path, userLog, (err) => {})
}
}
module.exports = Logger;