You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 5def2ff
Browse filesBrowse the repository at this point in the historyBrowse files
authored
fix(logs): Support Logger block syntax in Sentry.logger (#3178)
* fix: Add block syntax support to StructuredLogger for compatibility
Ruby's Logger supports passing the message as a block. For Sentry's structured logger
to be used interchangeably with Ruby's logger, it should also support this syntax.
* fix(logs): Support block syntax in DebugStructuredLogger
DebugStructuredLogger overrides every level method and #log with a required
message, so block syntax raised ArgumentError when it was configured as the
logger class. Accept an optional message and resolve it from the block there
too.
Raise a clear ArgumentError when neither a message nor a block is given,
instead of letting nil reach LogEvent and fail with NoMethodError. Use
yield/block_given? in the plain #log methods; the level methods keep &block
only to forward it (Ruby 2.7 has no anonymous block forwarding, and
define_method cannot yield).
Refs #2911
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(logs): Let the block take precedence over the positional argument
Ruby's Logger treats the positional argument of its level methods as the
progname when a block is given, and logs the block's result as the message.
Match that so callers like info("request") { details } log the details
instead of the progname.
Refs #3177
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Jérôme Parent-Lévesque <jerome.parent-levesque@potloc.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
0 commit comments