Browse Source

Fixing logging and build version parsing

develop
Drew Short 5 years ago
parent
commit
15f9a196ff
  1. 2
      bot/bot.js
  2. 2
      bot/engine.js
  3. 9
      bot/logging.js
  4. 3
      bot/utility.js
  5. 4
      entrypoint.sh

2
bot/bot.js

@ -100,7 +100,7 @@ class Bot {
}
function create(config) {
let buildInfo = utility.getBuildInfo("../build.info")
let buildInfo = utility.getBuildInfo();
logger.info("Running version: %s", buildInfo);
return new Bot(config, buildInfo);
}

2
bot/engine.js

@ -24,7 +24,7 @@ class Engine {
this.modules.forEach((mod) => {
logger.info("Loading module: %s", mod.name);
initModule(mod);
console.log("Recognized commands: %s", mod.getRecognizedCommands())
logger.infog("Recognized commands: %s", mod.getRecognizedCommands())
this.moduleMap.set(mod.command, mod);
this.commandMap.set(mod.command, mod);
this.commandRadixTree.addWord(mod.command);

9
bot/logging.js

@ -20,10 +20,17 @@ if (process.env.NODE_ENV !== 'production') {
winston.format.simple()
)
}));
} else {
logger.add(new winston.transports.Console({
level: 'error',
format: winston.format.combine(
winston.format.simple()
)
}));
}
if ('LOG_LEVEL' in process.env) {
logger.info('LOG_LEVEL:', process.env.LOG_LEVEL)
logger.info('LOG_LEVEL: %s', process.env.LOG_LEVEL)
logger.level = process.env.LOG_LEVEL
}

3
bot/utility.js

@ -26,7 +26,8 @@ function toISODateString(d) {
+ pad(d.getUTCSeconds()) + 'Z'
}
function getBuildInfo(buildInfoPath) {
function getBuildInfo() {
let buildInfoPath = process.env.NODE_PATH + '/build.info';
try {
return fs.readFileSync(buildInfoPath, "utf8");
} catch (err) {

4
entrypoint.sh

@ -7,9 +7,13 @@ echo "NODE_ENV: ${NODE_ENV}"
echo "NODE_PATH: ${NODE_PATH}"
echo "LOG_LEVEL: ${LOG_LEVEL}"
echo "Running build version: $(cat build.info)"
case $1 in
run)
echo "Baphomet Starting..."
node index.js
echo "...Baphomet Shutdown"
;;
*)
echo "\"$1\" is an unrecognized command"

Loading…
Cancel
Save