Repository navigation
feat: Add Write-SentryLog cmdlet for structured logs - #131
Merged
Merged
Conversation
Wraps SentrySdk.Logger with a PowerShell-native API so users don't have to call params object[] overloads with [object[]] coercion. Supports all six log levels, message templates with positional parameters, and structured attributes via a hashtable. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
|
Mirrors the sample from PR #122 but uses the new cmdlet, including the -Parameters and -Attributes flags. Also fixes the changelog entry to include the PR number so Danger picks it up. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
jamescrosswell
approved these changes
May 25, 2026
jamescrosswell
left a comment
Collaborator
There was a problem hiding this comment.
Cool, thanks @vaind - this was a good one to read to get my head around PS modules... relatively simple for a PS expert like yourself but plenty of new concepts for a noob like me.
LGTM (FWIW) 👍🏻
vaind
added a commit
that referenced
this pull request
Sep 7, 2026
Write-SentryLog (#131) and the move of its options off Experimental (#133) both land in this same unreleased cycle, so no released version ever exposed $_.Experimental.SetBeforeSendLog through the module. There is nothing for a user upgrading from 0.4.0 to migrate. Reaching past the module into the bundled SDK's options object was the only way to touch it from 0.4.0, and the Dependencies entry for the 5.16.1 -> 6.10.0 bump already covers that surface. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
vaind
added a commit
that referenced
this pull request
Sep 7, 2026
* chore: update dependencies/Sentry.properties to 6.10.0 * docs: Drop the Logs opt-in from the send-logs sample sentry-dotnet 6.10.0 removed the EnableLogs gate on SentrySdk.Logger, which is what Write-SentryLog calls. Setting $_.EnableLogs = $true no longer has any bearing on whether Write-SentryLog emits, so the sample's "opt in to Logs" guidance now teaches something untrue. Verified against the bundled 6.10.0 assembly: a log envelope item reaches the transport with EnableLogs both set and unset, where 6.5.0 emitted only when it was set. No test covers the disabled path, which is why the change was invisible to CI. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * Configure Sentry client with DSN and debug mode * docs: Fold the Logs opt-in note into the Write-SentryLog entry Write-SentryLog and the SDK bump that removed the EnableLogs gate both land in the same unreleased cycle, so describing the removal as its own entry documents a change no released version ever exposed. Readers of the next release only need to know the cmdlet exists, so reference #137 from the entry that introduced it instead. Drop the EnableLogs half of the breaking-changes entry for the same reason: it directed readers to set $_.EnableLogs, which is no longer required for Write-SentryLog to emit. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * docs: Drop the Experimental breaking-change entry Write-SentryLog (#131) and the move of its options off Experimental (#133) both land in this same unreleased cycle, so no released version ever exposed $_.Experimental.SetBeforeSendLog through the module. There is nothing for a user upgrading from 0.4.0 to migrate. Reaching past the module into the bundled SDK's options object was the only way to touch it from 0.4.0, and the Dependencies entry for the 5.16.1 -> 6.10.0 bump already covers that surface. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * docs: Credit #133 on the Write-SentryLog entry #133 moved the Logs options off Experimental and updated the sample and tests accordingly, so it shaped the logging surface users see. Its attribution lived in the breaking-change entry that was just removed; fold it into the feature entry rather than losing it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- Co-authored-by: GitHub <noreply@github.com> Co-authored-by: Ivan Dlugos <dlugos.ivan@gmail.com> Co-authored-by: Claude Opus 5 <noreply@anthropic.com> Co-authored-by: Ivan Dlugos <6349682+vaind@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
Write-SentryLog, a native PowerShell cmdlet for sending structured logs (Sentry Logs, currentlyExperimental.EnableLogs).Without it, users have to call the underlying .NET API directly — e.g.
[Sentry.SentrySdk]::Logger.LogInfo('User {0} ran {1}', [object[]]@($user, $script))— because PowerShell doesn't auto-expandparams object[]. The cmdlet hides that ceremony behind familiar PowerShell ergonomics.The cmdlet:
-LeveltoInfo-Messagefrom the pipeline (position 0)Logger.Log<Level>(...)overloadAction<SentryLog>overload usingSetAttributeOut-Sentry's behaviorTests use
Experimental.SetBeforeSendLog(...)to capture log records and assert on level, template, message substitution, parameter array, and attributes.Addresses #122 (comment) — the sample in #122 should be updated to use this cmdlet once this lands (follow-up).
Test plan
Invoke-Pester ./tests/write-sentrylog.tests.ps1— 7/7 passInvoke-Pester ./tests) — 72 passed, 3 skipped (pre-existing)🤖 Generated with Claude Code