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
8181docs] ( ./docs/logging.md ) for more information. You can, however, also create
8282breadcrumbs manually:
8383
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: {
8594 # "ty": "log",
8695 # "level": "debug",
8796 # "category": "myapp.models",
8897 "message": "hi"
8998 })
9099
100+ The callback will only be called if a sentry client is configured.
101+
102+
91103## Concurrency
92104
93105* 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):
152152 itself."""
153153 pass
154154
155- def add_breadcrumb (self , crumb ):
155+ def add_breadcrumb (self , * args , ** kwargs ):
156156 """Adds a breadcrumb."""
157157 client , scope = self ._stack [- 1 ]
158158 if client is None :
159159 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+
162166 if crumb is not None :
163167 scope ._breadcrumbs .append (crumb )
164168 while len (scope ._breadcrumbs ) >= client .options ["max_breadcrumbs" ]:
You can’t perform that action at this time.
0 commit comments