Skip to content

feat: add sentry_log() for plain-string log messages#1566

Merged
jpnurmi merged 4 commits intomasterfrom
jpnurmi/feat/log-plain
Mar 9, 2026
Merged

feat: add sentry_log() for plain-string log messages#1566
jpnurmi merged 4 commits intomasterfrom
jpnurmi/feat/log-plain

Conversation

@jpnurmi
Copy link
Collaborator

@jpnurmi jpnurmi commented Mar 7, 2026

Add sentry_log() — a non-printf API that accepts a plain string body and explicit attributes for downstream SDKs.

The existing sentry_log_*() functions treat the message as a printf format string. When callers like sentry-godot pass pre-formatted user text as the message, any % characters cause undefined behavior. On MSVC, %n kills the process immediately.

Notice that using "%s" together with a pre-formatted string as the first parameter is not a viable workaround (getsentry/sentry-godot#577) because it would clobber the sentry.message.parameter.0 attribute.

The new sentry_log() overload skips printf interpretation and parameter extraction entirely, preserving the caller's attributes as-is.

See also:

Add a non-printf API that accepts a plain string body and explicit
attributes. This avoids UB when user-provided text contains `%`
characters, and prevents the SDK's parameter extraction from clobbering
caller-provided `sentry.message.parameter.*` attributes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link

github-actions bot commented Mar 7, 2026

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 7d59ef4

Copy link
Collaborator

@limbonaut limbonaut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@limbonaut
Copy link
Collaborator

Godot SDK PR with this branch and a test:

Copy link
Collaborator

@supervacuus supervacuus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@jpnurmi jpnurmi merged commit 25a956e into master Mar 9, 2026
83 of 84 checks passed
@jpnurmi jpnurmi deleted the jpnurmi/feat/log-plain branch March 9, 2026 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants