Skip to content

Commit

Permalink
Create logger move to logger.js lib
Browse files Browse the repository at this point in the history
  • Loading branch information
Ellen Fawkes committed Aug 29, 2017
1 parent e4dc0d4 commit 5f403dd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
8 changes: 8 additions & 0 deletions lib/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@ function initLogger(parrentLogger) {
}); // Setup logger
}

function createLogger(prefix) {
var _logger = new console.Console(process.stdout, process.stderr);
_logger.prefix = prefix;
initLogger(_logger); // Init new logger at derivation
return _logger;
}

exports.init = initLogger;
exports.createLogger = createLogger;
11 changes: 2 additions & 9 deletions purrplingbot.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ var cmds = {

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

// Print info about PurrplingBot
logger.info("* Starting PurrplingBot version " + VERSION + " '" + CODENAME + "'");
Expand Down Expand Up @@ -102,13 +102,6 @@ function init() {
bot.login(config.discord.token);
}

function createLogger(prefix) {
var _logger = new console.Console(process.stdout, process.stderr);
_logger.prefix = prefix;
LOGGER.init(_logger); // Init new logger at derivation
return _logger;
}

function print_cmd_help(cmd) {
var prefix = config.cmdPrefix;
if (cmd.startsWith(prefix)) {
Expand Down Expand Up @@ -261,7 +254,7 @@ exports.addCommand = function(cmdName, cmdObject) {
}

// createLogger() availaible for all modules
exports.createLogger = createLogger;
exports.createLogger = LOGGER.createLogger;

//Take init() bot outside main file (call it in another module after require)
exports.init = init
Expand Down

0 comments on commit 5f403dd

Please sign in to comment.