add typescript to backend
This commit is contained in:
parent
0a41568a2e
commit
30b28056de
10 changed files with 221 additions and 67 deletions
|
|
@ -1,33 +0,0 @@
|
|||
const fs = require("fs");
|
||||
|
||||
class Logger {
|
||||
constructor(filePath) {
|
||||
this.filePath = "/logs/app.log";
|
||||
}
|
||||
|
||||
log(level, message, params) {
|
||||
const logEntry = {
|
||||
timestamp: new Date().toISOString(),
|
||||
level: level,
|
||||
message: message,
|
||||
params: params,
|
||||
};
|
||||
fs.appendFile(this.filePath, JSON.stringify(logEntry) + "\n", (err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
}
|
||||
|
||||
info(message, params = {}) {
|
||||
this.log("info", message, params);
|
||||
}
|
||||
|
||||
warn(message, params = {}) {
|
||||
this.log("warn", message, params);
|
||||
}
|
||||
|
||||
error(message, params = {}) {
|
||||
this.log("error", message, params);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Logger;
|
||||
Loading…
Add table
Add a link
Reference in a new issue