Skip to content

No way to get diagnostics off a device, and Release logs only warnings anyway #112

Closed

Description

@zhollis21

Problem

When something goes wrong in the app there is no way to get diagnostics out of it. A user hitting
odd behaviour has nothing to send, and testing on a real phone means the useful detail stays on the
device.

The obvious shape is a Settings action that ships the log somewhere. The catch is that the log a
Release build keeps does not contain the things worth sending.

What the log actually holds today

The file log's minimum level is build-dependent (src/AniSprinkles/MauiProgram.cs):

// Debug
var fileLogMinimumLevel = LogLevel.Debug;   // :56

// Release
var fileLogMinimumLevel = LogLevel.Warning; // :67

Every trace the app emits is Information:

// DetailsPageModelBase.cs:99
Logger.LogInformation("PageState: {OldState} → {NewState} (key={StateKey})", ...);
// DetailsPageModelBase.cs:306
Logger.LogInformation("NAVTRACE {TracePrefix} load start ({EntityNoun} {Id})", ...);

So in a shipped build the file at {AppDataDirectory}/logs holds warnings and errors and nothing
else — no NAVTRACE, no PageState, no CACHE, no AUTH. A share button built today would
faithfully deliver a file missing exactly what makes a report diagnosable.

Retention is 256 KB across 3 rotated files in Release (MauiProgram.cs:69) and 1 MB in Debug
(MauiProgram.cs:58); the 1 MB in FileLoggerProvider.cs:12 is the constructor default that only
Debug passes. So whatever level is chosen, the window is finite — and in Release it is a quarter of
what this issue originally assumed.

Options

Settled at kickoff: none of A/B/C — a fourth shape, D. An in-memory ring buffer
ILoggerProvider holding roughly the last five minutes at Information, bounded by both age and
line count, written to disk only when a global exception handler fires or the activity pauses. A
report bundles the current ring plus the last flushed session. The file log stays at Warning in
Release, unchanged.

D beat B because B pays a write cost on every install and shrinks the already-small 256 KB Release
window. It beat C because, although the full traces are already in logcat at Debug in every build
config (MauiProgram.cs:92-94, so C needed a reader rather than new logging), logcat lives in the
app project where no unit test can reach it and its buffer is shared with the rest of the system. D
lives in Core, so eviction is testable on FakeTimeProvider. It beat A for the reason A already
gives against itself.

The three below are kept for the record.

A. Opt-in verbose toggle. A Settings switch that raises the file-log level to Information while
on. Normal installs keep today's write cost and privacy posture; the user turns it on, reproduces,
sends. The cost is that it must be enabled before the problem happens, which is the wrong order for
anything intermittent.

B. Always persist Information in Release. Traces are always there when needed, and there is no
second step at the worst moment. Every install pays the write cost, and the 1 MB / 3-file window
fills faster, so it holds proportionally less history.

C. Capture the live logcat buffer at share time. Leaves the file log alone and reads Android's
process log when the user taps share. Full traces, no persistent cost — but only covers the current
process, so it dies with a restart, and it is Android-specific in a way the file logger is not.

A and B trade privacy and cost against catching intermittent faults, and C trades durability for
completeness. D takes C's zero-persistent-cost shape and buys back most of the durability with the
handler and pause flushes, at the price of holding the buffer in RAM.

Audience

Both, and they pull differently:

  • Testing on a real phone. Wants an artifact immediately, in hand.
  • A user reporting a problem. Wants it to reach the maintainer without asking anything of them.

Delivery should attach the log to Sentry, which is already wired and is where crash reports
already land.

Resolved at kickoff: Sentry only, no share-sheet path. Sentry's silence is handled by making the
send explicit at both ends rather than by adding a second delivery route — a popup states what is
about to be collected before anything is sent, and the confirmation names it back ("Diagnostics sent
— last 5 minutes of activity"). The popup also carries an optional free-text box for what the user
was doing, sent as SentryFeedback with AssociatedEventId set to the diagnostic event, so the
description arrives as a linked user report rather than buried in an event body.

Note for implementation: SentryScrubber runs on SetBeforeSend over the SentryEvent and does
not touch attachments, so the bundle has to be redacted where it is built. The free-text
description needs the same pass — a user can paste anything into it.

Constraint

  • Bearer-token redaction is bypassed for the log file and Sentry #124 has landed. ErrorReportService previously redacted Bearer tokens from the string shown
    in the UI but handed the raw exception to ILogger and Sentry, and AniListClient embeds up to
    500 characters of raw response body in exception messages — so the log could carry an unredacted
    credential. That was the blocker on this issue and it is now closed. Re-verify the redaction holds
    on whichever path ships, because this feature turns a passive leak into an active one.
  • A real user's log is their data. List contents, media ids, and account identifiers can all
    appear. Whatever ships should be clear about what is being sent.
  • File-log retention is 256 KB / 3 files in Release. Raising the level would shorten the history
    the user can send, which is part of why the ring buffer is separate from it.

Related

Activity

  1. added
    p2-high
    Tech Debt
    on Jul 30, 2026
  2. zhollis21 commented on Aug 22, 2026

    @zhollis21
    OwnerAuthor

    Dependency worth knowing about before this ships: #124.

    ErrorReportService redacts Bearer tokens out of the string it returns to the UI, but hands the raw exception to ILogger and Sentry — so the rotating file log this issue proposes sharing can contain unredacted tokens. AniListClient embeds up to 500 characters of the raw HTTP response body into exception messages, so an auth-failure body that echoes the credential reaches the log.

    Passive today. A share button would make it active exfiltration, so #124 should land first.

    Separately, the observation in this issue's own framing still stands and is worth re-checking during implementation: Release persists only Warning and above while every trace in the app (NAVTRACE, PageState, CACHE, AUTH) is Information, so the shipped button would deliver a file missing exactly what makes a report useful.

  3. changed the title [-]Enable Diagnostic Logging[/-] [+]No way to get diagnostics off a device, and Release logs only warnings anyway[/+] on Aug 26, 2026
  4. zhollis21 commented on Sep 2, 2026

    @zhollis21
    OwnerAuthor

    Verification notes from kickoff, against origin/main @ 0fa0729. Facts only.

    Retention figure in the body has drifted. Release passes 256 KB / 3 files, not 1 MB
    (MauiProgram.cs:69). The 1 MB in FileLoggerProvider.cs:12 is the constructor default, and only
    Debug passes it (MauiProgram.cs:58). So the Release window is a quarter of what this issue assumes.

    The full traces already reach logcat in every build config. AndroidLogcatLoggerProvider is
    registered unconditionally at LogLevel.Debug (MauiProgram.cs:92-94), with a comment saying so
    explicitly. NAVTRACE, PageState, CACHE and AUTH are all in the Android log buffer of a
    Release build right now — what is missing is capture and delivery, not the data. That changes the
    cost of option C: it needs no new logging, only a reader.

    The app is Android-only — <TargetFrameworks>net10.0-android</TargetFrameworks>
    (AniSprinkles.csproj:4). Option C's "Android-specific" cost is not a cost against today's targets.

    #124 is closed (2026-08-24). Redaction is SensitiveText.Redact applied at the source in
    AniListClient, plus SentryScrubber on SetBeforeSend (MauiProgram.cs:36). Note the asymmetry:
    the scrubber only sees Sentry events. The file log and logcat have no sink-side pass, so they depend
    entirely on source-side redaction holding.

    The log sinks carry more URI than the breadcrumbs do. LoggingHandler logs the full
    RequestUri (LoggingHandler.cs:34, :50), while the matching Sentry breadcrumb trims to
    GetLeftPart(UriPartial.Path) (:35). Anything in a query string is in the file log and logcat but
    not in Sentry.

    A NotFound failure currently produces the least evidence of any error path:

    • logged at Warning, deliberately not sent to Sentry (DetailsPageModelBase.cs:348-353)
    • details is suppressed to string.Empty (DetailsPageModelBase.cs:369)
    • ErrorStateView's Copy and Share are gated on HasErrorDetails (ErrorStateView.xaml.cs:115,
      :132), so the error card for a NotFound has no share affordance at all
    • ClassifyGraphQlError maps any message containing "Not Found" to ApiErrorKind.NotFound and
      non-retryable (AniListErrorClassifier.cs:56)

    Sentry breadcrumbs are already broadly instrumented — navigation, HTTP, auth, and list actions
    across MediaListPageModel, MediaDetailsPageModel, SettingsPageModel, EntryActionCoordinator
    and DetailsPageModelBase. Any explicit CaptureMessage inherits that trail.

    Settings' content is gated on sign-in. SettingsLoadedContentView is only attached when
    IsAuthenticated && CurrentState == Content (SettingsPage.xaml.cs:148-149), so anything placed
    inside it is unreachable while signed out. The signed-out branch lives in SettingsPage.xaml:34-58.

    Existing share precedent: Share.Default.RequestAsync(new ShareTextRequest ...) in
    ErrorStateView.xaml.cs:134-139.

    Related open issues in the same area: #149 (airing worker's faults reach only logcat) and #156
    (unhandled Android exceptions swallowed silently).

  5. zhollis21 commented on Sep 3, 2026

    @zhollis21
    OwnerAuthor

    Updated during planning:

    • Retention figure corrected: Release is 256 KB / 3 files (MauiProgram.cs:69), not the 1 MB the body claimed. That 1 MB is FileLoggerProvider.cs:12's constructor default and only Debug passes it.
    • Options section resolved. None of A/B/C — an in-memory ring buffer at Information, flushed to disk only on the global exception handlers and on activity pause, with the file log left at Warning. Reasoning recorded in the body.
    • Delivery question resolved: Sentry only. The silence is handled by a disclosure popup before the send and a confirmation that names what went, rather than by adding a share-sheet route. The popup also takes an optional free-text description, sent as SentryFeedback linked to the diagnostic event.

    Also in scope for the same PR, tracked separately: the NotFound path currently produces no Sentry event, no details string, and therefore no Copy/Share affordance on the error card, so the exact failure that prompted this work is the one nothing can report.

  6. zhollis21 commented on Sep 3, 2026

    @zhollis21
    OwnerAuthor

    Filed #158 for the NotFound blind spot. Same PR, but tracked separately so the diagnostics pipeline and the error-path fix each have their own record.

  7. added a commit that references this issue on Nov 19, 2026
    7848da2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Tech Debtp2-high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions