This repository was archived by the owner on Sep 12, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +34
-28
lines changed Expand file tree Collapse file tree 5 files changed +34
-28
lines changed Original file line number Diff line number Diff line change 2
2
3
3
import logging
4
4
import logging .handlers
5
- import os
6
5
import platform
7
6
import sys
8
7
9
8
from . import toolkit
9
+ from .extras import bugsnag
10
10
from .lib import config
11
11
from .server import __version__
12
12
import flask
@@ -59,22 +59,6 @@ def root():
59
59
return toolkit .response (cfg .issue )
60
60
61
61
62
- def bugsnag (application , api_key , flavor , version ):
63
- # Configure bugsnag
64
- if api_key :
65
- import bugsnag
66
- import bugsnag .flask
67
-
68
- root_path = os .path .abspath (os .path .dirname (os .path .dirname (__file__ )))
69
- bugsnag .configure (api_key = api_key ,
70
- project_root = root_path ,
71
- release_stage = flavor ,
72
- notify_release_stages = [flavor ],
73
- app_version = version
74
- )
75
- bugsnag .flask .handle_exceptions (application )
76
-
77
-
78
62
def init ():
79
63
# Configure the email exceptions
80
64
info = cfg .email_exceptions
@@ -95,7 +79,7 @@ def init():
95
79
secure = secure_args )
96
80
mail_handler .setLevel (logging .ERROR )
97
81
app .logger .addHandler (mail_handler )
98
- bugsnag (app , cfg .bugsnag , cfg .flavor , __version__ )
82
+ bugsnag . boot (app , cfg .bugsnag , cfg .flavor , __version__ )
99
83
# Configure flask_cors
100
84
for i in cfg .cors .keys ():
101
85
app .config ['CORS_%s' % i .upper ()] = cfg .cors [i ]
Original file line number Diff line number Diff line change
1
+ # -*- coding: utf-8 -*-
2
+
3
+ import os
4
+
5
+
6
+ def boot (application , api_key , flavor , version ):
7
+ # Configure bugsnag
8
+ if api_key :
9
+ import bugsnag
10
+ import bugsnag .flask
11
+
12
+ root_path = os .path .abspath (
13
+ os .path .dirname (os .path .dirname (os .path .dirname (__file__ ))))
14
+ bugsnag .configure (api_key = api_key ,
15
+ project_root = root_path ,
16
+ release_stage = flavor ,
17
+ notify_release_stages = [flavor ],
18
+ app_version = version
19
+ )
20
+ bugsnag .flask .handle_exceptions (application )
Original file line number Diff line number Diff line change
1
+ # -*- coding: utf-8 -*-
2
+
3
+
4
+ def boot (ini , stage ):
5
+ if ini :
6
+ try :
7
+ import newrelic .agent
8
+ newrelic .agent .initialize (ini , stage )
9
+ except Exception as e :
10
+ raise Exception ('Failed to init new relic agent %s' % e )
Original file line number Diff line number Diff line change 3
3
4
4
import logging
5
5
6
+ from .extras import newrelic
6
7
from .server import env
7
-
8
- _new_relic_ini = env .source ('NEW_RELIC_INI' )
9
- if _new_relic_ini :
10
- try :
11
- import newrelic .agent
12
- newrelic .agent .initialize (
13
- _new_relic_ini ,
14
- env .source ('NEW_RELIC_STAGE' ))
15
- except Exception as e :
16
- raise (Exception ('Failed to init new relic agent %s' % e ))
8
+ newrelic .boot (env .source ('NEW_RELIC_INI' ), env .source ('NEW_RELIC_STAGE' ))
17
9
18
10
from .extensions import factory
19
11
factory .boot ()
You can’t perform that action at this time.
0 commit comments