From c680a6efa302f2dacc01a59de34e4267dfd1e637 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Fri, 8 Dec 2017 10:25:05 -0800 Subject: [PATCH] updated slack config file --- config/slackConfig.js | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/config/slackConfig.js b/config/slackConfig.js index 84ab3376..109671f2 100644 --- a/config/slackConfig.js +++ b/config/slackConfig.js @@ -4,27 +4,30 @@ const winstonSlackWebHook = require('winston-slack-webhook').SlackWebHook; module.exports = (winston) => { if (config.logging.slackWebHook) { // add a transport for errors to slack - winston.add(winstonSlackWebHook, { - name : 'slack-errors-transport', - level : 'warn', - webhookUrl: config.logging.slackWebHook, - channel : config.logging.slackErrorChannel, - username : 'spee.ch', - iconEmoji : ':face_with_head_bandage:', - }); - winston.add(winstonSlackWebHook, { - name : 'slack-info-transport', - level : 'info', - webhookUrl: config.logging.slackWebHook, - channel : config.logging.slackInfoChannel, - username : 'spee.ch', - iconEmoji : ':nerd_face:', - }); + if (config.logging.slackErrorChannel) { + winston.add(winstonSlackWebHook, { + name : 'slack-errors-transport', + level : 'warn', + webhookUrl: config.logging.slackWebHook, + channel : config.logging.slackErrorChannel, + username : 'spee.ch', + iconEmoji : ':face_with_head_bandage:', + }); + }; + if (config.logging.slackInfoChannel) { + winston.add(winstonSlackWebHook, { + name : 'slack-info-transport', + level : 'info', + webhookUrl: config.logging.slackWebHook, + channel : config.logging.slackInfoChannel, + username : 'spee.ch', + iconEmoji : ':nerd_face:', + }); + }; // send test message winston.error('Slack "error" logging is online.'); - winston.warn('Slack "warning" logging is online.'); winston.info('Slack "info" logging is online.'); } else { - winston.warn('Slack logging is not enabled because no SLACK_WEB_HOOK env var provided.'); + winston.warn('Slack logging is not enabled because no slackWebHook config var provided.'); } };