Logging in JavaScript


Hi everyone,

New guy here. I’m currently trying to create my own bot in JavaScript. I’m having some trouble with logging, though. I originally had been trying to run “console.log” calls to check values of various things, but that interferes with the normal operation of the game.

So instead I’ve been trying to use the included logging library, but nothing I put in a “logging.info” or a “logging.debug” call is printing out to my console or the generated log on an error. Am I doing something wrong?

Also, is there a way to force a log to be created even if the bot runs successfully? I didn’t see an option in the ‘halite’ program to do this.

Thanks for your help!


P.S. Click to see original answer, some formatting is missed.


The code from the starter file working fine for me to print debug info into a local bot-0.log file…
Haven’t decided if I like es6 template strings with the tricky back single qoute or the previous + style yet:

const logging = require(’./hlt/logging’);

_logging.info(` ATTACK! My ship ID is ${ship.id} `);
_logging.info(“ATTACK! My ship ID is” + ship.id);