File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -81,13 +81,25 @@ anywhere in your system ends up as a breadcrumb, see [the logging
81
81
docs] ( ./docs/logging.md ) for more information. You can, however, also create
82
82
breadcrumbs manually:
83
83
84
- sentry_sdk.add_breadcrumb({
84
+ sentry_sdk.add_breadcrumb(
85
+ # ty="log",
86
+ # level="debug",
87
+ # category="myapp.models",
88
+ message="hi"
89
+ })
90
+
91
+ You can also pass a callback to ` add_breadcrumb ` like so:
92
+
93
+ sentry_sdk.add_breadcrumb(lambda: {
85
94
# "ty": "log",
86
95
# "level": "debug",
87
96
# "category": "myapp.models",
88
97
"message": "hi"
89
98
})
90
99
100
+ The callback will only be called if a sentry client is configured.
101
+
102
+
91
103
## Concurrency
92
104
93
105
* Sentry-Python currently does not support gevent-based setups.
Original file line number Diff line number Diff line change @@ -152,13 +152,17 @@ def capture_internal_exception(self, error=None):
152
152
itself."""
153
153
pass
154
154
155
- def add_breadcrumb (self , crumb ):
155
+ def add_breadcrumb (self , * args , ** kwargs ):
156
156
"""Adds a breadcrumb."""
157
157
client , scope = self ._stack [- 1 ]
158
158
if client is None :
159
159
return
160
- if callable (crumb ):
161
- crumb = crumb ()
160
+
161
+ if not kwargs and len (args ) == 1 and callable (args [0 ]):
162
+ crumb = args [0 ]()
163
+ else :
164
+ crumb = dict (* args , ** kwargs )
165
+
162
166
if crumb is not None :
163
167
scope ._breadcrumbs .append (crumb )
164
168
while len (scope ._breadcrumbs ) >= client .options ["max_breadcrumbs" ]:
You can’t perform that action at this time.
0 commit comments