File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change
1
+ import logging
2
+ import os
3
+ import structlog
4
+ from structlog import get_logger
5
+
6
+ import sentry_sdk
7
+ from dotenv import load_dotenv
8
+
9
+ LOG_LEVEL = os .environ .get ("LOG_LEVEL" , "INFO" )
10
+
11
+ if os .environ .get ("SENTRY_DSN" ):
12
+ sentry_sdk .init (dsn = os .environ ["SENTRY_DSN" ])
13
+
14
+ def get_logger (name ):
15
+ structlog .configure (
16
+ processors = [
17
+ structlog .processors .TimeStamper (fmt = "iso" ),
18
+ structlog .processors .StackInfoRenderer (),
19
+ structlog .processors .format_exc_info ,
20
+ structlog .processors .KeyValueRenderer (key_prefix = " " ),
21
+ structlog .processors .JSONRenderer (),
22
+ ],
23
+ logger_factory = structlog .stdlib .LoggerFactory (),
24
+ cache_logger_on_first_use = True ,
25
+ wrapper_class = structlog .stdlib .BoundLogger ,
26
+ context_class = dict ,
27
+ level = LOG_LEVEL ,
28
+ )
29
+
30
+ return get_logger (name )
You can’t perform that action at this time.
0 commit comments