core: an empty DARNER_LOG means unset, not "log nothing" #572
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
hle
input
INTEL
lighting
linux-proton
memory
MULDER
needs-info
needs-logs
needs-rebase
NVIDIA
performance
post-merge
pr-diagnostics
pr-docs
pre-merge
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
relevance
high
relevance
low
relevance
medium
relevance
very-high
rendering
report
roadmap-proposal
saves
series-s
shaders
startup
status
blocked-by-rework
status
needs-test-report
status
needs-triage
status
ready-for-review
status
stale
status
superseded
status
wip
tools
ui
upstream
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
TrustNo1/Darner!572
Loading…
Reference in a new issue
No description provided.
Delete branch "qnjk/Darner:logging-empty-filter"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Contributor role (optional)
What it changes
The problem on main:
logging::initreadsDARNER_LOGwithstd::env::var("DARNER_LOG").ok()and asks forRUST_LOGonly when that isNone:and
resolve_filterthen doesdarner_log.or(rust_log).and_then(|v| EnvFilter::try_new(v).ok()). A defined-but-empty variable isOk(""), notNone, andEnvFilter::try_new("")returnsOkwith zero directives — a filter that enables nothing. SoDARNER_LOG=(reachable fromdarner play --set DARNER_LOG=, or from any launcher that passes a variable through with nothing set) logged not one line to the console or to the log filedarner playnames, skipped theRUST_LOGfallback the module doc promises, and never reached the default level either. It was the only environment read in the crate where""meant "log nothing" instead of "unset":config.rs:100'senv_pathand this file's ownDARNER_LOG_FILEboth filter empty.This change adds one helper,
non_empty(value: Option<&str>), which drops a blank value (including whitespace-only), and applies it to both lookups insideresolve_filter, keeping the orderDARNER_LOG→RUST_LOG→default_level.initnow reads both variables; which one wins staysresolve_filter's single decision, so the fallback is actually reachable whenDARNER_LOGis present but empty. No other behaviour changes.How it was tested
7f51e5e(one commit onc8258f9).cargo test --locked -p darner-core --lib— 51 passed, 0 failed.logging::tests::empty_log_variables_count_as_unsetpins: emptyDARNER_LOGusesRUST_LOG(error); emptyRUST_LOGuses the default (info); both empty uses the default; whitespace-only counts as empty; a non-emptyDARNER_LOGstill wins over an emptyRUST_LOG. It touches no environment — the helper takes the values as arguments.cargo clippy --locked -p darner-core --all-targets -- -D warningspasses.DARNER_LOG/RUST_LOGis used exactly as before; only a blank value changes, and it now means "unset" as it does everywhere else in the tree.cargo clippy --workspace --all-targets --locked -- -D warnings: passes.cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passes.cargo test --workspace --locked: not run to completion here; the pre-existingdarner-gputest deadlock (#224) and thedarner-shaderwaterfall fixture failure (#227) make the whole-workspace run non-green on this machine, and neither crate is touched by this change.darner-core's suite is green (51 passed).darner play --set DARNER_LOG=; the helper and the ordering are pinned by the test. The log-file path (DARNER_LOG_FILE) was not re-checked with an emptyDARNER_LOG.Checklist
main.main.docs/asset-policy.md. (cargo xtask policy: 576 files ok.)Checked for overlap
crates/darner-core/src/logging.rs(checked against the file list of all 189 open pull requests), and no open or closed issue mentionsDARNER_LOGbeing empty.A defined but empty filter variable makes `std::env::var` return `Ok("")`, and `EnvFilter::try_new("")` returns `Ok` with no directive at all: a filter with no directive enables nothing. A run with `DARNER_LOG=` therefore logged not one line, at the console or in the file `darner play` names, and never fell back to `RUST_LOG` as the module doc says it does, nor to the default level. Treat a present-but-empty value as unset in `resolve_filter`, as every other environment value in this crate does (`config.rs::env_path`, and `DARNER_LOG_FILE` in this module), and read `RUST_LOG` even when `DARNER_LOG` is defined, so the fallback the module documents actually runs. The new test pins the fallback: an empty `DARNER_LOG` uses `RUST_LOG`, and an empty pair uses the default level.Tested merged onto
c8258f95(release), head7f51e5ed. RTX 3090 24 GB, driver 621.24, i5-10600K, 32 GB, Windows 11.One unattended run per build, 60 s in the world after the first frame (
DARNER_EXIT_AFTER_WORLD_S=60), with--set DARNER_LOG=(defined but empty):main(c8258f95): the log file has 1 line (the header) and nothing else.DARNER_LOG.Both exited with code 0. So the empty value now falls back as described. Not tested:
RUST_LOGset at the same time, or a value made only of spaces.AI-assisted testing (Claude Code, Claude Opus 5.5); results and text reviewed by me.
[pr-fix] core: an empty DARNER_LOG means unset, not "log nothing"to core: an empty DARNER_LOG means unset, not "log nothing"View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.