logger func to better know when and where soemthing was logged
This commit is contained in:
parent
37022eaa6d
commit
0c238dd9f1
10 changed files with 83 additions and 31 deletions
|
|
@ -1,7 +1,10 @@
|
|||
import fs from 'fs'
|
||||
import GameCommon from '../common/GameCommon.js'
|
||||
import { logger } from '../common/Util.js'
|
||||
import Game from '../server/Game.js'
|
||||
|
||||
|
||||
const log = logger('fix_tiles.js')
|
||||
|
||||
function fix_tiles(gameId) {
|
||||
Game.loadGame(gameId)
|
||||
let changed = false
|
||||
|
|
@ -12,14 +15,14 @@ function fix_tiles(gameId) {
|
|||
if (p.x === tile.pos.x && p.y === tile.pos.y) {
|
||||
// console.log('all good', tile.pos)
|
||||
} else {
|
||||
console.log('bad tile pos', tile.pos, 'should be: ', p)
|
||||
log.log('bad tile pos', tile.pos, 'should be: ', p)
|
||||
tile.pos = p
|
||||
GameCommon.setTile(gameId, tile.idx, tile)
|
||||
changed = true
|
||||
}
|
||||
} else if (tile.owner !== 0) {
|
||||
tile.owner = 0
|
||||
console.log('unowning tile', tile.idx)
|
||||
log.log('unowning tile', tile.idx)
|
||||
GameCommon.setTile(gameId, tile.idx, tile)
|
||||
changed = true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
import fs from 'fs'
|
||||
import Protocol from '../common/Protocol.js'
|
||||
import { logger } from '../common/Util.js'
|
||||
|
||||
const log = logger('rewrite_logs')
|
||||
|
||||
const DATA_DIR = '../data'
|
||||
|
||||
|
|
@ -7,7 +10,7 @@ const filename = (gameId) => `${DATA_DIR}/log_${gameId}.log`
|
|||
|
||||
const rewrite = (gameId) => {
|
||||
const file = filename(gameId)
|
||||
console.log(file)
|
||||
log.log(file)
|
||||
if (!fs.existsSync(file)) {
|
||||
return []
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue