-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig.js
More file actions
50 lines (40 loc) · 1.39 KB
/
config.js
File metadata and controls
50 lines (40 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// config.js
import { createWriteStream } from 'fs';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
import { mkdirSync } from 'fs';
const webOptions = {
ip_web: '127.0.0.1',
port_web: 17392,
secretToken: 'HTTP_TOKEN'
};
const rconOptions = {
host: '127.0.0.1',
port: 21114,
password: 'RCON_PASSWORD',
autoReconnectDelay: 1000
};
const rconPoolSize = 1; // Warning, using more than 1 connection currently will cause a bug.
const logLevel = 1; // 0 = only essential, 5 = all logs
const enableLogging = true; // Set to false to disable logging
// Utility function for logging
function logger(component, level, message) {
if (level <= logLevel) {
console.log(`[${new Date().toISOString()}] [${level}] [${component}] ${message}`);
}
}
if (enableLogging) {
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const logDir = join(__dirname, './log');
mkdirSync(logDir, { recursive: true });
const logFileName = `${new Date().toISOString().replace(/:/g, '-')}.log`;
const logFilePath = join(logDir, logFileName);
const logStream = createWriteStream(logFilePath, { flags: 'a' });
console.log = message => {
const formattedMessage = `${message}`;
process.stdout.write(formattedMessage + '\n');
logStream.write(formattedMessage + '\n');
};
}
export { webOptions, rconOptions, rconPoolSize, logger };