From 2869c23aa205bf75145e8abf428687e7a6261bd2 Mon Sep 17 00:00:00 2001 From: Pedro Pombeiro Date: Wed, 28 Mar 2018 17:58:26 +0200 Subject: [PATCH] Log output to console if running attached to debugger --- .vscode/launch.json | 5 ++++- index.js | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index b326524..9a3abc3 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -22,7 +22,10 @@ "program": "${workspaceFolder}/node_modules/probot/bin/probot-run.js", "args": [ "${workspaceFolder}/index.js" - ] + ], + "env": { + "DEBUG": "true" + } }, { "type": "node", diff --git a/index.js b/index.js index b13bc65..be2c69a 100644 --- a/index.js +++ b/index.js @@ -2,6 +2,14 @@ const Slack = require('./lib/slack') module.exports = async (robot) => { console.log('Yay, the app was loaded!') + if (process.env.DEBUG) { + // HACK: If we're attached to the debugger, send output to console + robot.log.error = console.log + robot.log.warn = console.log + robot.log.info = console.log + robot.log.debug = console.log + robot.log.trace = console.log + } await setupSlack(robot)