added check for slack env vars
This commit is contained in:
parent
d15c6f076b
commit
7d0fda64f7
3 changed files with 33 additions and 31 deletions
|
@ -1,19 +1,20 @@
|
||||||
{
|
{
|
||||||
"WalletConfig": {
|
"WalletConfig": {
|
||||||
"LbryClaimAddress": "none",
|
"LbryClaimAddress": null,
|
||||||
"DefaultChannel": "none"
|
"DefaultChannel": null
|
||||||
},
|
},
|
||||||
"AnalyticsConfig":{
|
"AnalyticsConfig":{
|
||||||
"GoogleId": "none"
|
"GoogleId": null
|
||||||
},
|
},
|
||||||
"Database": {
|
"Database": {
|
||||||
"Database": "lbry",
|
"Database": "lbry",
|
||||||
"Username": "none",
|
"Username": null,
|
||||||
"Password": "none"
|
"Password": null
|
||||||
},
|
},
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": "none",
|
"LogLevel": null,
|
||||||
"SlackErrorChannel": "none",
|
"SlackWebHook": null,
|
||||||
"SlackInfoChannel": "none"
|
"SlackErrorChannel": null,
|
||||||
|
"SlackInfoChannel": null
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -12,10 +12,6 @@ module.exports = (winston, logLevel) => {
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
// winston.on('error', (err) => {
|
|
||||||
// console.log('unhandled exception in winston >> ', err);
|
|
||||||
// });
|
|
||||||
|
|
||||||
winston.error('Level 0');
|
winston.error('Level 0');
|
||||||
winston.warn('Level 1');
|
winston.warn('Level 1');
|
||||||
winston.info('Level 2');
|
winston.info('Level 2');
|
||||||
|
|
|
@ -5,7 +5,8 @@ const SLACK_INFO_CHANNEL = config.get('Logging.SlackInfoChannel');
|
||||||
const winstonSlackWebHook = require('winston-slack-webhook').SlackWebHook;
|
const winstonSlackWebHook = require('winston-slack-webhook').SlackWebHook;
|
||||||
|
|
||||||
module.exports = (winston) => {
|
module.exports = (winston) => {
|
||||||
// add a transport for errors
|
if (SLACK_WEB_HOOK) {
|
||||||
|
// add a transport for errors to slack
|
||||||
winston.add(winstonSlackWebHook, {
|
winston.add(winstonSlackWebHook, {
|
||||||
name : 'slack-errors-transport',
|
name : 'slack-errors-transport',
|
||||||
level : 'error',
|
level : 'error',
|
||||||
|
@ -23,5 +24,9 @@ module.exports = (winston) => {
|
||||||
iconEmoji : ':nerd_face:',
|
iconEmoji : ':nerd_face:',
|
||||||
});
|
});
|
||||||
// send test message
|
// send test message
|
||||||
winston.error('Testing slack logging... slack logging is online.');
|
winston.error('Slack error logging is online.');
|
||||||
|
winston.info('Slack info logging is online.');
|
||||||
|
} else {
|
||||||
|
winston.error('Slack logging is not enabled because no SLACK_WEB_HOOK env var provided.');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue