@@ -20,6 +20,8 @@ global.mongoDisconnected = false;
20
20
global . winston = require ( 'winston' ) ;
21
21
expressWinston = require ( 'express-winston' ) ;
22
22
require ( 'winston-loggly' ) ;
23
+ var slack = require ( 'winston-bishop-slack' ) . Slack ;
24
+ var util = require ( 'util' ) ;
23
25
24
26
global . keys = require ( './database-connect/keys.js' ) ( ) ;
25
27
@@ -36,6 +38,31 @@ global.winston.add(global.winston.transports.Loggly, {
36
38
json : true
37
39
} ) ;
38
40
41
+ // add slack transport if API key found
42
+ if ( global . keys . slackWebHook ) {
43
+ var envVal = process . env [ "IS_STAGING" ] ? 'STAGING' : 'PRODUCTION'
44
+ global . winston . add ( slack , {
45
+ webhook_url : global . keys . slackWebHook ,
46
+ icon_url : "https://cdn2.iconfinder.com/data/icons/circle-icons-1/64/caution-128.png" ,
47
+ channel : "#devlogs" ,
48
+ username : "API ERROR BOT - " + envVal ,
49
+ level : 'error' ,
50
+ handleExceptions : true ,
51
+ customFormatter : function ( level , message , meta ) {
52
+ return { attachments : [ {
53
+ fallback : "An Error occured on API POD in - " + envVal ,
54
+ pretext : "An Error occured on API POD in - " + envVal ,
55
+ color : '#D00000' ,
56
+ fields : [ {
57
+ title : util . format ( ":scream_cat: %s" , 'Critical Error' ) ,
58
+ value : meta . error ,
59
+ short : false
60
+ } ]
61
+ } ] }
62
+ }
63
+ } )
64
+ }
65
+
39
66
global . keyService = require ( './database-connect/keyService.js' ) ;
40
67
41
68
global . q = require ( 'q' ) ;
0 commit comments