prisma (#1)
migrate from knex to prisma on backend Co-authored-by: fred <> Reviewed-on: #1
This commit is contained in:
parent
24281a6322
commit
0a41568a2e
31 changed files with 1577 additions and 472 deletions
33
backend/src/utils/logger.js
Normal file
33
backend/src/utils/logger.js
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
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