Skip to content

Commit

Permalink
fix: Logger
Browse files Browse the repository at this point in the history
  • Loading branch information
cyperdark committed Feb 19, 2024
1 parent ae72f56 commit 82e049e
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions packages/common/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ STATIC_FOLDER_PATH=./static`
);
}

dotenv.config({ path: configPath });

export const config = {
debugLogging: (process.env.DEBUG_LOG || '') === 'true',
calculatePP: (process.env.CALCULATE_PP || '') === 'true',
Expand Down Expand Up @@ -110,11 +112,11 @@ export const updateConfigFile = () => {
};

export const watchConfigFile = ({ httpServer }: { httpServer: Server }) => {
configureLogger();

refreshConfig(httpServer, false);
updateConfigFile();

configureLogger();

fs.watchFile(configPath, (current, previous) => {
refreshConfig(httpServer, true);
});
Expand All @@ -134,19 +136,14 @@ export const refreshConfig = (httpServer: Server, refresh: boolean) => {
const serverIP = parsed.SERVER_IP || '127.0.0.1';
const serverPort = Number(parsed.SERVER_PORT || '24050');

if (config.debugLogging != debugLogging) {
config.debugLogging = debugLogging;

configureLogger();
}

if (config.serverIP != serverIP || config.serverPort != serverPort) {
config.serverIP = serverIP;
config.serverPort = serverPort;

httpServer.restart();
}

config.debugLogging = debugLogging;
config.calculatePP = (parsed.CALCULATE_PP || '') === 'true';
config.enableKeyOverlay = (parsed.ENABLE_KEY_OVERLAY || '') === 'true';
config.pollRate = Number(parsed.POLL_RATE || '500');
Expand All @@ -155,4 +152,5 @@ export const refreshConfig = (httpServer: Server, refresh: boolean) => {
config.enableGosuOverlay = (parsed.ENABLE_GOSU_OVERLAY || '') === 'true';

wLogger.info(`Config ${status}ed`);
configureLogger();
};

0 comments on commit 82e049e

Please sign in to comment.