fix: add some logs

This commit is contained in:
2023-10-22 20:50:38 +02:00
parent b1e98b7a77
commit f9e86ede08
2 changed files with 11 additions and 1 deletions

View File

@@ -37,10 +37,15 @@ app.get('/metrics', async (req, res) => {
try {
const client = new SourceRcon.default(config.ip, Number.parseInt(config.port));
console.log(`[${config.game} ${config.ip}:${config.port}] connecting`);
await client.connect();
console.log(`[${config.game} ${config.ip}:${config.port}] connected`);
await client.auth(config.rconPassword);
console.log(`[${config.game} ${config.ip}:${config.port}] auth`);
const response = await module.request(config, client);
console.log(`[${config.game} ${config.ip}:${config.port}] request`);
await module.send(config, response, res);
console.log(`[${config.game} ${config.ip}:${config.port}] send`);
} catch (e) {
if (e.code === 'EHOSTUNREACH') {
console.error(`Unreachable host : ${e.address}:${e.port}`);

View File

@@ -21,8 +21,13 @@ export default {
},
async rconCommand(client, command) {
try {
return client.send(command);
console.log(`[${client.host}:${client.port}] rcon command :`, command);
const res = await client.send(command);
console.log(`[${client.host}:${client.port}] rcon commands result: ${command}`);
console.log(res);
return res;
} catch (err) {
throw err;
}
return null;