Add a child logger to the Game
This commit is contained in:
parent
8bede05e07
commit
21c9034ab6
2 changed files with 7 additions and 1 deletions
|
|
@ -11,7 +11,11 @@ export default (io: Server, socket: Socket, data: CreateGame) => {
|
||||||
let game = new Game(conf, host);
|
let game = new Game(conf, host);
|
||||||
games[game.id] = game;
|
games[game.id] = game;
|
||||||
game.players.push(host);
|
game.players.push(host);
|
||||||
log.info(`New game created with ID ${game.id} (host=${host.name})`);
|
game.log = log.getChildLogger({
|
||||||
|
displayLoggerName: true,
|
||||||
|
name: game.id,
|
||||||
|
})
|
||||||
|
game.log.info(`New game created (host=${host.name})`);
|
||||||
|
|
||||||
socket.join(game.id);
|
socket.join(game.id);
|
||||||
socket.emit(`GameCreated`, {
|
socket.emit(`GameCreated`, {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import { Team } from "./Team";
|
import { Team } from "./Team";
|
||||||
import { Deck } from "./Deck";
|
import { Deck } from "./Deck";
|
||||||
|
import { Logger } from "tslog";
|
||||||
import { games } from "../main";
|
import { games } from "../main";
|
||||||
import { Player } from "./Player";
|
import { Player } from "./Player";
|
||||||
import { readFileSync } from "fs";
|
import { readFileSync } from "fs";
|
||||||
|
|
@ -7,6 +8,7 @@ import { readFileSync } from "fs";
|
||||||
export class Game {
|
export class Game {
|
||||||
readonly id: string;
|
readonly id: string;
|
||||||
readonly host: Player;
|
readonly host: Player;
|
||||||
|
public log: Logger;
|
||||||
public ingame: boolean;
|
public ingame: boolean;
|
||||||
public teams: [Team, Team];
|
public teams: [Team, Team];
|
||||||
public players: Player[];
|
public players: Player[];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue