File tree 1 file changed +8
-20
lines changed
1 file changed +8
-20
lines changed Original file line number Diff line number Diff line change
1
+ import flask .logging
2
+
1
3
from distutils .version import StrictVersion
2
4
from pkg_resources import get_distribution
3
5
6
8
# Try to monkey-patch Flask, if installed
7
9
try :
8
10
9
- # Only patch 0.12 (in case logging changes in 0.13)
11
+ # Only patch >= 1.0
10
12
version = StrictVersion (get_distribution ("flask" ).version )
11
- assert version >= StrictVersion ("0.10" ) and version < StrictVersion ("0.13" )
12
-
13
- # Get default logger
14
- import flask .logging
15
- f = flask .logging .create_logger
16
-
17
- def create_logger (app ):
18
- """Wrap default logger"""
19
-
20
- # Create default logger
21
- logger = f (app )
22
-
23
- # Reformat default logger's exceptions
24
- # https://docs.python.org/3/library/logging.html#logging.Formatter.formatException
25
- for handler in logger .handlers :
26
- handler .formatter .formatException = lambda exc_info : formatException (* exc_info )
27
- return logger
13
+ assert version >= StrictVersion ("1.0" )
28
14
29
- # Replace default logger
30
- flask .logging .create_logger = create_logger
15
+ # Reformat logger's exceptions
16
+ # http://flask.pocoo.org/docs/1.0/logging/
17
+ # https://docs.python.org/3/library/logging.html#logging.Formatter.formatException
18
+ flask .logging .default_handler .formatter .formatException = lambda exc_info : formatException (* exc_info )
31
19
32
20
except :
33
21
pass
You can’t perform that action at this time.
0 commit comments