Skip to content

Commit

Permalink
Update Logs (#43)
Browse files Browse the repository at this point in the history
* fix(Log): add date on api log

* fix(Log): stringify data

* fix(Log): stringify data
  • Loading branch information
KevOneRedOne authored Dec 6, 2023
1 parent 53fe97e commit 5b55bb7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ app.use((req, res, next) => {
if (process.env.STACK === 'development') {
const currentTime = new Date().toISOString();
const clientIp = req.headers['x-forwarded-for'] || req.socket.remoteAddress;
console.log(`[${currentTime}] - Requête reçue : ${req.method}, ${req.url}, ${JSON.stringify(req.params)}, ${JSON.stringify(req.body)} , | de IP: [${clientIp}] `);
console.log(`[${currentTime}] - Requête reçue : ${req.method}, ${req.url}, ${JSON.stringify(req.params)}, ${JSON.stringify(req.body)} | de l'adresse IP: [${clientIp}] `);

if (req.method === 'POST' || req.method === 'PUT') {
console.log('Corps de la requête :', req.body);
console.log(`[${currentTime}] - Corps de la requête : ${JSON.stringify(req.body)} | de l'adresse IP: [${clientIp}] `);
}
}
res.setHeader('Access-Control-Allow-Origin', '*');
Expand Down

0 comments on commit 5b55bb7

Please sign in to comment.