From 16c9376a557980d58a441df9101b918d182a8a95 Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Sat, 10 Oct 2020 01:38:23 -0600 Subject: [PATCH] Add a constants file so that we don't need to have constants in the class files. --- src/constants.ts | 16 ++++++++++++++++ src/main.ts | 7 ++++--- src/types/constants.d.ts | 1 + 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 src/constants.ts create mode 100644 src/types/constants.d.ts diff --git a/src/constants.ts b/src/constants.ts new file mode 100644 index 0000000..601884f --- /dev/null +++ b/src/constants.ts @@ -0,0 +1,16 @@ +/* +The level for the logger to display, can be one of the following: + "silly" + "debug" + "info" + "error" + "warn" + "fatal" + "trace" +defaults to "info" +*/ +export const LOG_LEVEL: log_level = `silly`; +export const LOG_NAME: string = `Secret Hitler`; + + +export const WSS_PORT: number = 3000; \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index c91e397..b9551d3 100644 --- a/src/main.ts +++ b/src/main.ts @@ -17,14 +17,15 @@ import { ChancellorPolicy } from "./events/ChancellorPolicy"; import { PresidentPolicies } from "./events/PresidentPolicies"; import { ChancellorNomination } from "./events/ChancellorNomination"; import { ExecutiveConfirmation } from "./events/ExecutiveConfirmation"; +import { LOG_LEVEL, LOG_NAME, WSS_PORT } from "./constants"; export var log: Logger = new Logger({ displayFunctionName: false, displayLoggerName: false, displayFilePath: `hidden`, displayLogLevel: true, - minLevel: `silly`, - name: `SecretHitler`, + minLevel: LOG_LEVEL || `info`, + name: LOG_NAME, }); export var active_games: {[key: string]: Game} = {}; @@ -50,7 +51,7 @@ function clean_up() { process.on(`uncaughtException`, clean_up); process.on('SIGINT', clean_up); -const io = sio.listen(3000); +const io = sio.listen(WSS_PORT); io.on(`connection`, (socket: sio.Socket) => { log.silly(`Client connected with id ${socket.id}`); diff --git a/src/types/constants.d.ts b/src/types/constants.d.ts new file mode 100644 index 0000000..8e91af5 --- /dev/null +++ b/src/types/constants.d.ts @@ -0,0 +1 @@ +type log_level = "silly"|"debug"|"info"|"error"|"warn"|"fatal"|"trace"; \ No newline at end of file