Add a constants file so that we don't need to have constants in the class files.

This commit is contained in:
Oliver-Akins 2020-10-10 01:38:23 -06:00
parent 03db868b7c
commit 16c9376a55
3 changed files with 21 additions and 3 deletions

16
src/constants.ts Normal file
View file

@ -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;

View file

@ -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}`);

1
src/types/constants.d.ts vendored Normal file
View file

@ -0,0 +1 @@
type log_level = "silly"|"debug"|"info"|"error"|"warn"|"fatal"|"trace";