Commit b598368
committed
fix: defer migration warning until after tracing subscriber is initialised
In my infinite wisdom, my previous commit attempted to fix the silent
migration warning by calling init_logging("warn") before Config::load.
The real problem was that load_json_and_migrate fires tracing::warn! from inside
Config::load, but the subscriber can only be initialised after Config::load
returns, because the user's log_level lives inside the config that hasn't
been read yet. Classic chicken-and-egg. Locking to "warn" early meant the
second init_logging(&config.log_level) call was a silent no-op (try_init
semantics), so users lost their configured log level entirely.
Fix: instead of logging directly inside load_json_and_migrate, collect
the warning as an Option<String> and return it alongside the Config up
the call chain. main.rs logs it with tracing::warn! after
init_logging(&config.log_level) — one subscriber, correct level,
migration warning visible with proper timestamp and severity.
Config::load return type changes from Result<Self> to
Result<(Self, Option<String>)>; load_toml paths return None, the JSON
migration path returns Some(message). Test call sites updated with .0
to destructure the tuple.1 parent 7c9d6da commit b598368
2 files changed
Lines changed: 24 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
551 | 551 | | |
552 | 552 | | |
553 | 553 | | |
554 | | - | |
| 554 | + | |
555 | 555 | | |
556 | 556 | | |
557 | 557 | | |
558 | 558 | | |
559 | 559 | | |
560 | 560 | | |
561 | 561 | | |
562 | | - | |
| 562 | + | |
563 | 563 | | |
564 | 564 | | |
565 | 565 | | |
566 | 566 | | |
567 | 567 | | |
568 | 568 | | |
569 | | - | |
| 569 | + | |
570 | 570 | | |
571 | 571 | | |
572 | 572 | | |
573 | | - | |
| 573 | + | |
574 | 574 | | |
575 | 575 | | |
576 | 576 | | |
| |||
587 | 587 | | |
588 | 588 | | |
589 | 589 | | |
590 | | - | |
| 590 | + | |
591 | 591 | | |
592 | 592 | | |
593 | 593 | | |
| |||
596 | 596 | | |
597 | 597 | | |
598 | 598 | | |
599 | | - | |
| 599 | + | |
600 | 600 | | |
601 | | - | |
| 601 | + | |
602 | 602 | | |
603 | 603 | | |
604 | 604 | | |
605 | 605 | | |
606 | | - | |
607 | | - | |
| 606 | + | |
| 607 | + | |
608 | 608 | | |
609 | 609 | | |
610 | | - | |
611 | | - | |
612 | | - | |
| 610 | + | |
| 611 | + | |
613 | 612 | | |
614 | | - | |
| 613 | + | |
615 | 614 | | |
616 | 615 | | |
617 | 616 | | |
618 | | - | |
619 | | - | |
620 | | - | |
621 | | - | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
622 | 621 | | |
623 | 622 | | |
624 | 623 | | |
| |||
1216 | 1215 | | |
1217 | 1216 | | |
1218 | 1217 | | |
1219 | | - | |
| 1218 | + | |
1220 | 1219 | | |
1221 | 1220 | | |
1222 | 1221 | | |
| |||
1280 | 1279 | | |
1281 | 1280 | | |
1282 | 1281 | | |
1283 | | - | |
| 1282 | + | |
1284 | 1283 | | |
1285 | 1284 | | |
1286 | 1285 | | |
| |||
1412 | 1411 | | |
1413 | 1412 | | |
1414 | 1413 | | |
1415 | | - | |
| 1414 | + | |
1416 | 1415 | | |
1417 | 1416 | | |
1418 | 1417 | | |
| |||
1434 | 1433 | | |
1435 | 1434 | | |
1436 | 1435 | | |
1437 | | - | |
| 1436 | + | |
1438 | 1437 | | |
1439 | 1438 | | |
1440 | 1439 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
204 | | - | |
205 | | - | |
| 204 | + | |
206 | 205 | | |
207 | 206 | | |
208 | 207 | | |
| |||
215 | 214 | | |
216 | 215 | | |
217 | 216 | | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
218 | 220 | | |
219 | 221 | | |
220 | 222 | | |
| |||
0 commit comments