Skip to content

Commit

Permalink
Fixed logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Ellen Fawkes committed Aug 31, 2017
1 parent cfa5fcc commit 8964e6e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function initLogger(logger) {

function createLogger(prefix, out = process.stdout, errOut = process.stderr) {
var logger = new console.Console(out, errOut);
logger.prefix = prefix;
logger.prefix = prefix || "";
initLogger(logger); // Init new logger at derivation
return logger;
}
Expand Down
18 changes: 11 additions & 7 deletions purrplingbot.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,26 +70,30 @@ var cmds = {
};

function check_conf() {
console.prefix = "Config";
if (!config.discord) {
console.error("Discord scope not defined in config!");
logger.error("Discord scope not defined in config!");
process.exit(6);
}
if (!config.discord.token) {
console.error("Token not defined in discord scope!");
logger.error("Token not defined in discord scope!");
process.exit(6);
}
console.log("Configuration is OK!");
logger.log("Configuration check is OK!");
}

function print_bot_info() {
var _logger = LOGGER.createLogger();
_logger.info("* Starting PurrplingBot version " + VERSION + " '" + CODENAME + "'");
_logger.info("* Runtime: Node " + process.version + "(" + process.platform + ") Pid: " + process.pid);
_logger.info("* Argv: " + process.argv);
}

function init() {
// Init main logger
logger = LOGGER.createLogger("Core");

// Print info about PurrplingBot
logger.info("* Starting PurrplingBot version " + VERSION + " '" + CODENAME + "'");
logger.info("* Runtime: Node " + process.version + "(" + process.platform + ") Pid: " + process.pid);
logger.info("* Argv: " + process.argv);
print_bot_info();
if (DEBUG > 0) logger.log("* DEBUG MODE ENABLED !! (level: %s)", DEBUG);

// Load configuration file
Expand Down

0 comments on commit 8964e6e

Please sign in to comment.