-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
34 lines (31 loc) · 1.06 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import sentry_sdk
from sentry_sdk.integrations.logging import LoggingIntegration
import logging
from datetime import datetime as dt
import logging
# All of this is already happening by default!
sentry_logging = LoggingIntegration(
level=logging.INFO, # Capture info and above as breadcrumbs
event_level=logging.ERROR # Send errors as events
)
sentry_sdk.init(
dsn="your_sentry_dns",
integrations=[sentry_logging]
)
"""
https://docs.sentry.io/platforms/python/logging/
"""
def capture_exception():
try:
trying = 1/0
except Exception as e:
sentry_sdk.capture_exception(Exception(e))
def capture_message():
sentry_sdk.capture_message("Start logging message ======= ")
def capture_logger_info():
logging.error(f"Capture logger info {dt.now().strftime('%Y%m%d %H:%M:%S')}========",
extra={'event': 'capture',
#'date': dt.now().strftime("%Y%m%d %H:%M:%S"),
'user': {'email': '[email protected]'},
'tags': {'database': '1.0'},
})