Begin using the tslog module

This commit is contained in:
Oliver-Akins 2020-10-01 21:45:40 -06:00
parent 1578df961c
commit 564206dd8b
2 changed files with 10 additions and 6 deletions

View file

@ -13,7 +13,7 @@ that the host is able to just send that to the other players
*/
import * as db from '../utils/db';
import { Socket } from 'socket.io';
import { active_games } from '../main';
import { active_games, log } from '../main';
import { generate_game_code } from '../utils/gamecode';
export const HostGame = (socket: Socket, data: HostGame) => {
@ -29,7 +29,7 @@ export const HostGame = (socket: Socket, data: HostGame) => {
active_games[game_code] = game;
console.log(`${data.username} created a game. (Gamecode: ${game_code})`);
log.info(`${data.username} created a game. (Gamecode: ${game_code})`);
// Respond to client
socket.emit(`HostInformation`, {
@ -38,11 +38,11 @@ export const HostGame = (socket: Socket, data: HostGame) => {
players: [data.username]
});
} catch (err) {
log.error(err);
// Let client know an error occured
socket.emit(`HostInformation`, {
success: false,
error: `${err.name}: ${err.message}`
})
});
}
};