Skip to content

Commit

Permalink
Added logging game-access data
Browse files Browse the repository at this point in the history
  • Loading branch information
matlorr committed Oct 11, 2024
1 parent b77afeb commit 2022fa9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ client/dist
games/
server/.lake
**/.DS_Store
logs/
12 changes: 12 additions & 0 deletions relay/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ const server = app
const lang = req.params.lang

const ip = anonymize(req.headers['x-forwarded-for'] || req.socket.remoteAddress)
const log = `${process.env.HOME}/lean4game/logs/game-access.log`
const header = "date;anon-ip;game;lang\n"
const data = `${new Date()};${ip};${owner}/${repo};${lang}\n`

fs.writeFile(log, header.concat(data), { flag: 'ax' }, (file_exists) => {
if (file_exists) {
fs.appendFile(log, data, (err) => {
if (err) console.log("Failed to append to log!")
});
}
});

console.log(`[${new Date()}] ${ip} requested translation for ${owner}/${repo} in ${lang}`)

const filename = req.params[0];
Expand Down

0 comments on commit 2022fa9

Please sign in to comment.