Repository navigation
Conversation
Diagnostics written with eprintln! go to stderr, which a packaged Tauri app does not have, so those lines are lost in the field and bug reports arrive without them. Install a tracing subscriber with two sinks: stderr as before, and a daily-rolling file in the platform log dir with five files kept. Both honour RUST_LOG. Panics and anything logging through the log crate are routed into the same sinks, so a crash leaves a record on disk. The existing append_to_file / append_to_diag trail is deliberately left alone; this covers the stderr half only.
Every diagnostic eprintln! becomes a leveled tracing macro, so the same lines now reach the file sink and can be filtered with RUST_LOG rather than being all-or-nothing on stderr. Levels follow what the line is for: info! for scan results and state changes, debug! for per-cycle detail, warn! for dropped scans and failed fetches, error! for failures that lose data. Values that used to be formatted into the message become structured fields. The bracketed prefixes are gone, since the subscriber prints the module target instead, except where the prefix named something finer than the module, which becomes an explicit target.
Spans on the capture, OCR, blob-parse and fetch entry points, so the file sink records how long each stage took rather than only what it printed. The subscriber emits span-close events, which carry time.busy and time.idle. warframe.market calls needed a shape change to be timed at all: every site built a request with wfm_request and then issued the call itself, so a span on the builder would have measured struct construction rather than the round-trip. Two helpers, wfm_call and wfm_send_json, now wrap the request and the call together, and all sites route through them.
Contributor
Author
|
thank you for integrating the PRs into the main repo! verified it on/against the linux branch, and everything is working well! |
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.
feat(logging): route diagnostics through tracing with a rolling file sink
Three commits, meant to be reviewed in order: subscriber, then the mechanical
eprintln!sweep, then the spans. If you want the first and not the rest, thefirst stands alone.
The problem, stated narrowly. There are 40
eprintln!/println!diagnosticsacross
lib.rs,memory_scanner.rsandwfcd.rs. They go to stderr, which apackaged Tauri app does not have, so in the field they go nowhere. They are also
all-or-nothing: there is no way to ask a user for scanner detail without asking for
everything.
What this is not. You already have file logging:
append_to_file/append_to_diag, 35 call sites, writing%TEMP%\frameforge_riven_session.txtandthe per-session
diagnostics/tree. This change does not touch any of it. Iconsidered folding it in and decided against it. That trail is what you debug riven
OCR with, its format is presumably load-bearing for you, and I cannot run the
Windows path to check I had not made your debugging worse. So the two coexist after
this PR, which is a real wart and worth saying out loud rather than leaving for you
to notice. Unifying them is a separate conversation, and yours to start.
What lands.
feat(logging): add a tracing subscriber with a rolling file sink. Newsrc-tauri/src/logging.rs(93 lines), four dependencies,mod logging;, and alogging::init(app.handle())at the top ofsetup. Two sinks: stderr asbefore, and a daily-rolling file in the platform log dir (
app_log_dir(), Tauri'sown resolver) keeping five files. Both filtered by
RUST_LOG. A panic hookrecords panics with location before delegating to the previous hook, and
tracing_log::LogTracercaptures anything logging through thelogcrate.Writing is non-blocking so the scanner and OCR loops never stall on disk.
refactor(logging): replace eprintln diagnostics with tracing macros, themechanical sweep. Levels follow intent:
info!for results and state changes,debug!for per-cycle detail,warn!for dropped scans and failed fetches,error!where data is lost. Values formatted into messages become structuredfields. This commit is boring by design and should read at a glance.
feat(logging): instrument the scan, OCR and market paths. Spans on thecapture, OCR, blob-parse and fetch entry points; the subscriber emits span-close
events carrying
time.busy/time.idle, so the log records how long eachstage took. warframe.market needed a small shape change to be timeable at all:
every site built a request with
wfm_requestand issued the call itself, so aspan on the builder would have timed struct construction. Two helpers,
wfm_callandwfm_send_json, wrap request and call together; 15 sites routethrough them. Two of those were
.send_string(&body.to_string())and are nowwfm_send_json(..., &body), the same bytes on the wire, since the body wasalready a
serde_json::Value.Dependencies. Four:
tracing,tracing-appender,tracing-log,tracing-subscriber(withenv-filter). All MIT/Apache-2.0.Cargo.lockgrows by101 lines and nothing existing is bumped. I updated it surgically rather than
regenerating, because a full
cargo generate-lockfileon my machine rewrites 1,800lines and drags in
dbusandobjc2entries from my platform. Worth a sanity checkon your side that the lock still resolves the same for you.
Verification.
memory_scanner.rsconversions: the scanner tests run on Linux (7 passed) andthe Windows arm type-checks under
--target x86_64-pc-windows-gnu. That coversthe file with the most conversions.
lib.rs,wfcd.rs,ocr.rs: not compiled. Those files do not build on Linux(Win32 memory APIs, WinRT OCR), and I have no MSVC linker here. The conversions
are mechanical and mostly one-line, but "mechanical" is not "compiled" and you
should expect to fix at least a stray format-argument mismatch.
logging.rsitself has never run.app_log_dir()resolves on Windows bycontract, not by my having watched it.
If you reimplement this rather than taking the commits, the load-bearing parts are:
WorkerGuardmust outlive the process.tracing_appender::non_blockingreturns a guard whose drop flushes the buffer; dropping it at the end of
initmeans the last events, including the panic that made you look, never reach
disk. That is why it goes in a
OnceLock.loses the default backtrace behaviour.
initmust be idempotent. It is called fromsetup, and a second globalsubscriber install would otherwise panic or silently no-op depending on order.
the file to be as quiet as the console, which defeats the point: the file wants
debug, the console wantsinfo.FmtSpan::CLOSE. Without it the spans arestructure with no timings, which is most of what they are for.
wfm_call, notwfm_request. Timing the builder measures nothing.