Slack messaging #169

Merged
bones7242 merged 11 commits from slack-messaging into master 2017-09-21 21:11:32 +02:00
5 changed files with 38 additions and 3 deletions
Showing only changes of commit 915f55c0fb - Show all commits

View file

@ -5,5 +5,8 @@
"Database": {
"Username": "MYSQL_USERNAME",
"Password": "MYSQL_PASSWORD"
},
"Logging": {
"SlackWebHook": "SLACK_WEB_HOOK"
}
}

View file

@ -12,6 +12,10 @@ module.exports = (winston, logLevel) => {
],
});
// winston.on('error', (err) => {
// console.log('unhandled exception in winston >> ', err);
// });
winston.error('Level 0');
winston.warn('Level 1');
winston.info('Level 2');

View file

@ -0,0 +1,26 @@
const config = require('config');
const SLACK_WEB_HOOK = config.get('Logging.SlackWebHook');
const winstonSlackWebHook = require('winston-slack-webhook').SlackWebHook;
module.exports = (winston) => {
// add a transport for errors
winston.add(winstonSlackWebHook, {
name : 'slack-errors-transport',
level : 'error',
webhookUrl: SLACK_WEB_HOOK,
channel : '#speech-errors',
username : 'errorBot',
iconEmoji : ':face_with_head_bandage:',
});
winston.add(winstonSlackWebHook, {
name : 'slack-info-transport',
level : 'info',
webhookUrl: SLACK_WEB_HOOK,
channel : '#speech-logs',
username : 'infoBot',
iconEmoji : ':nerd_face:',
});
// send test message
winston.error('Testing slack logging... slack logging is online.');
};

View file

@ -39,7 +39,8 @@
"socket.io": "^2.0.1",
"socketio-file-upload": "^0.6.0",
"universal-analytics": "^0.4.13",
"winston": "^2.3.1"
"winston": "^2.3.1",
"winston-slack-webhook": "^0.1.5"
},
kauffj commented 2017-09-16 00:19:43 +02:00 (Migrated from github.com)
Review

should this be billbitt?

should this be billbitt?
bones7242 commented 2017-09-21 21:11:27 +02:00 (Migrated from github.com)
Review

I made my own fork to fix an issue with the package, and submitted a PR to the main package. The PR was accepted, so will update this to point to main package in next update.

I made my own fork to fix an issue with the package, and submitted a PR to the main package. The PR was accepted, so will update this to point to main package in next update.
"devDependencies": {
"eslint": "3.19.0",

View file

@ -14,7 +14,8 @@ const db = require('./models'); // require our models for syncing
// configure logging
const logLevel = config.get('Logging.LogLevel');
require('./config/loggerSetup.js')(logger, logLevel);
require('./config/loggerConfig.js')(logger, logLevel);
require('./config/slackLoggerConfig.js')(logger);
// trust the proxy to get ip address for us
app.enable('trust proxy');
@ -154,5 +155,5 @@ db.sequelize
});
})
.catch((error) => {
logger.error('Startup Error >>', error);
logger.error('Startup Error', error);
});