Skip to content

Commit

Permalink
Make game and player logging go to console again with the game code. …
Browse files Browse the repository at this point in the history
…Don't add hostname to the logs
  • Loading branch information
timjrobinson committed Aug 31, 2017
1 parent 5bfba8e commit 46fa569
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions gameserver/lib/player.coffee
Expand Up @@ -12,7 +12,7 @@ tdb = require('../../database')
rs = require 'randomstring'
serverConfig = require 'config/gameserver'
User = tdb.models.User
log = require('../../logger')
log = require('logger')
_ = require("lodash");
oberr = require("oberr");

Expand Down Expand Up @@ -96,7 +96,7 @@ class Player

joinGame: (@game) =>
@log = new (log.Logger)({
transports: log.getCustomTransports('gameserver', [@game.code])
transports: log.getCustomTransports('gameserver', [@game.get("code")])
})
@log.info("Player joining game")
@disconnected = false;
Expand Down Expand Up @@ -162,7 +162,7 @@ class Player
# each game when you join games. This will need to be fixed in the future when just the one
# player object is thrown around with tokens.
disconnect: =>
@log.info("Player is disconnecting", {code: @game.code})
@log.info("Player " + @id + " is disconnecting")
if @socket?
@socket.disconnect()
@disconnected = true
Expand Down
5 changes: 4 additions & 1 deletion gameserver/models/game.coffee
Expand Up @@ -16,7 +16,7 @@ connect = require 'connect'
netconfig = require 'config/netconfig'
bots = require './../lib/bots'
async = require 'async'
log = require('../../logger')
log = require('logger')
_ = require 'lodash'
metrics = require('../lib/metrics')
io = require("../lib/socket-io").io
Expand Down Expand Up @@ -506,11 +506,14 @@ class Game extends Model
kickPlayer: (requestingPlayerId, playerId) =>
@log.info("Kicking player")
if @get('state') != config.states.lobby
@log.info("Cannot kick player, game is not in lobby state")
return false;
if requestingPlayerId != @hostId
@log.info("Cannot kick player, requesting player is not the host")
return false
player = @getPlayer(playerId)
if !player
@log.info("Cannot kick player, player of id: ", playerId, " not found")
return false
player.kick();
@deletePlayer(player)
Expand Down
6 changes: 2 additions & 4 deletions logger/index.js
Expand Up @@ -11,7 +11,7 @@ if (config.datadog.api_key && config.datadog.app_keya) {

var env = process.env.NODE_ENV || "development";
var hostname = require('os').hostname().replace(/.tsinternal.towerstorm.com/, '').replace(/.towerstorm.com/, '');
var defaultTags = [hostname];
var defaultTags = [];


winston.init = function(appName) {
Expand Down Expand Up @@ -40,9 +40,7 @@ winston.getCustomTransports = function (appName, tags) {
var tagsFormatted = tags != null ? '[' + tags.join('] [') + '] ' : '';
tags = (tags || []).concat(defaultTags);
var transports = [];
if (process.env.DEBUG) {
transports.push(new (winston.transports.Console)({label: tags.join('][')}))
}
transports.push(new (winston.transports.Console)({label: tags.join('][')}))
return transports
};

Expand Down

0 comments on commit 46fa569

Please sign in to comment.