Skip to content

feat(crashpad): capture client & handler logs#1658

Draft
jpnurmi wants to merge 13 commits intomasterfrom
jpnurmi/feat/crashpad-log-file
Draft

feat(crashpad): capture client & handler logs#1658
jpnurmi wants to merge 13 commits intomasterfrom
jpnurmi/feat/crashpad-log-file

Conversation

@jpnurmi
Copy link
Copy Markdown
Collaborator

@jpnurmi jpnurmi commented Apr 17, 2026

Capture crashpad's client- and handler-side log output separately in the run directory: <run>/crashpad-client.log via logging::InitLogging on the client side, and <run>/crashpad-handler.log via --log-file= on the handler side. Both files are cleaned up with the rest of the .run directory on the next sentry_init, so they don't bloat the database.

When debug is enabled, also OR in LOG_TO_STDERR on the client side (so crashpad's client-side logs also tee to the app's stderr) and forward the SDK's log level to the handler via --log-level=N so the handler's log file matches the configured verbosity. TRACE and DEBUG map to mini_chromium's LOG_VERBOSE, FATAL to LOG_FATAL, the rest 1:1.

Examples:

>type .sentry-native\4dda4ca5-4a48-4ce2-833f-41f130ea74d9.run\crashpad-client.log
[9888:16876:20260417,172244.413:ERROR crashpad_client_win.cc:615] CreateProcess: %1 is not a valid Win32 application. (193)
[9888:16876:20260417,172253.264:ERROR crashpad_client_win.cc:153] crash server failed to launch, self-terminating
>type .sentry-native\503a7424-7c3f-4644-755a-4b2d0469dbc4.run\crashpad-handler.log
[18468:19016:20260417,172034.322:ERROR filesystem_win.cc:115] GetFileAttributes C:\Users\jpnurmi\Projects\sentry\sentry-playground\build\Desktop_Qt_6_9_1_MSVC2022_64bit-RelWithDebInfo\.sentry-native\attachments\3d5e3570-9cbd-4f6f-40f5-1bdd786d7254\__sentry-event: The system cannot find the file specified. (2)
[18468:19016:20260417,172034.323:ERROR filesystem_win.cc:115] GetFileAttributes C:\Users\jpnurmi\Projects\sentry\sentry-playground\build\Desktop_Qt_6_9_1_MSVC2022_64bit-RelWithDebInfo\.sentry-native\attachments\3d5e3570-9cbd-4f6f-40f5-1bdd786d7254\__sentry-breadcrumb1: The system cannot find the file specified. (2)
[18468:19016:20260417,172034.324:ERROR filesystem_win.cc:115] GetFileAttributes C:\Users\jpnurmi\Projects\sentry\sentry-playground\build\Desktop_Qt_6_9_1_MSVC2022_64bit-RelWithDebInfo\.sentry-native\attachments\3d5e3570-9cbd-4f6f-40f5-1bdd786d7254\__sentry-breadcrumb2: The system cannot find the file specified. (2)
[18468:19016:20260417,172034.377:ERROR filesystem_win.cc:115] GetFileAttributes C:\Users\jpnurmi\Projects\sentry\sentry-playground\build\Desktop_Qt_6_9_1_MSVC2022_64bit-RelWithDebInfo\.sentry-native\attachments\3d5e3570-9cbd-4f6f-40f5-1bdd786d7254\screenshot.png: The system cannot find the file specified. (2)

Close: #1468

See also:

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 17, 2026

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

Generated by 🚫 dangerJS against 173efed

jpnurmi and others added 5 commits April 17, 2026 12:50
Pass `--log-file=<run>/crashpad.log` to crashpad_handler so its log
output is written to the run directory alongside other session files.
The log is cleaned up with the rest of the `.run` directory on the
next `sentry_init`, so it doesn't bloat the database.

When `debug` is enabled, also forward the SDK's log level via
`--log-level=N` so the handler's log file matches the configured
verbosity (otherwise crashpad stays at its built-in default). TRACE
and DEBUG map to mini_chromium's `LOG_VERBOSE`, FATAL to `LOG_FATAL`,
the rest 1:1.

Closes #1468

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drop the default: branch so -Wswitch-enum is satisfied; INFO/WARNING/
ERROR map 1:1 via the cast-initialized default, TRACE/DEBUG collapse
to LOG_VERBOSE, FATAL is hardcoded to 4 since SENTRY_LEVEL_FATAL's
numeric value (3) collides with mini_chromium's LOG_ERROR_REPORT.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Write the client-side (via logging::InitLogging) and handler-side (via
--log-file=) output to <run>/crashpad-client.log and
<run>/crashpad-handler.log respectively. On options->debug, also tee
client-side logs to stderr.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jpnurmi jpnurmi force-pushed the jpnurmi/feat/crashpad-log-file branch from fe3e4d2 to bb9e626 Compare April 17, 2026 11:21
@jpnurmi jpnurmi changed the title feat(crashpad): capture handler log output to <run>/crashpad.log feat(crashpad): capture client & handler logs Apr 17, 2026
jpnurmi and others added 5 commits April 17, 2026 13:33
The client-side logging::InitLogging was not setting min_log_level, so
mini_chromium gated every message below LOG_INFO regardless of
options->debug. Lift the level-mapping switch out of the debug-only
block and also apply it to settings.min_log_level on the client side.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Bump mini_chromium to the lazy-open + thread-safety fix and drop the
file-existence assertions in the capture test — the happy path now
leaves no log file behind.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jpnurmi
Copy link
Copy Markdown
Collaborator Author

jpnurmi commented Apr 20, 2026

@JoshuaMoelans What do you think about <run>/crashpad-handler.log for the handler side, and then either STDERR and/or <run>/crashpad-client.log for the client side. We can pass LOG_TO_STDERR to the client, but then crashpad-client.log becomes kind of redundant.

P.S. Neither of them barely logs almost anything at all. They seem to be mostly errors only.

@JoshuaMoelans
Copy link
Copy Markdown
Member

@jpnurmi yeah that sounds good, it's where I would expect these logs to show up (crashpad being a different process, I also don't mind it not going to STDERR by default either)

@jpnurmi
Copy link
Copy Markdown
Collaborator Author

jpnurmi commented Apr 20, 2026

@JoshuaMoelans What about the client side that lives in the same process? It can also print useful errors, such as crashpad_handler missing +x on Linux. Here's a fabricated error with crashpad_handler.exe replaced by an empty file:

We can either capture client-side errors into STDERR so that it gets mixed in the sentry output (notice one message from crashpad_client_win.cc in the middle):

[sentry] INFO using database path "C:\Users\jpnurmi\Projects\sentry\sentry-playground\build\.sentry-native"
[sentry] DEBUG starting transport
[sentry] DEBUG starting background worker thread
[sentry] DEBUG submitting 100 ms delayed task to background worker thread
[sentry] DEBUG starting backend
[sentry] DEBUG background worker thread started
[sentry] DEBUG starting crashpad backend with handler "C:\Users\jpnurmi\Projects\sentry\sentry-playground\build\crashpad_handler.exe"
[sentry] DEBUG using minidump URL "https://127.0.0.1:12345/api/1/minidump/?sentry_client=sentry.native/0.13.7&sentry_key=aaa"
[19168:9228:20260420,170017.136:ERROR crashpad_client_win.cc:615] CreateProcess: %1 is not a valid Win32 application. (193)
[sentry] DEBUG registering crashpad WER handler "C:\Users\jpnurmi\Projects\sentry\sentry-playground\build\crashpad_wer.dll"
[sentry] WARN failed to start crashpad client handler
[sentry] WARN failed to initialize backend
[sentry] WARN `sentry_init` failed

Alternatively, we can capture it to <run>/crashpad-client.log:

C:\Users\jpnurmi\Projects\sentry\sentry-playground>type build\.sentry-native\c6a43bc8-2629-492d-e79c-94cb114aff09.run\crashpad-client.log
[19168:9228:20260420,170017.136:ERROR crashpad_client_win.cc:615] CreateProcess: %1 is not a valid Win32 application. (193)

Or, we can combine both so that you get crashpad-client.log and crashpad-handler.log side by side, even if the client-side logs appear in STDERR.

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.

Crashpad: improve logging for debugging purposes

2 participants