Log output to console if running attached to debugger

This commit is contained in:
Pedro Pombeiro 2018-03-28 17:58:26 +02:00
parent 91c337ad49
commit 2869c23aa2
No known key found for this signature in database
GPG Key ID: A65DEB11E4BBC647
2 changed files with 12 additions and 1 deletions

5
.vscode/launch.json vendored
View File

@ -22,7 +22,10 @@
"program": "${workspaceFolder}/node_modules/probot/bin/probot-run.js", "program": "${workspaceFolder}/node_modules/probot/bin/probot-run.js",
"args": [ "args": [
"${workspaceFolder}/index.js" "${workspaceFolder}/index.js"
] ],
"env": {
"DEBUG": "true"
}
}, },
{ {
"type": "node", "type": "node",

View File

@ -2,6 +2,14 @@ const Slack = require('./lib/slack')
module.exports = async (robot) => { module.exports = async (robot) => {
console.log('Yay, the app was loaded!') 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) await setupSlack(robot)