Commit efabe9b
Logging: fix live-console tearing (single-owner stdout) + suppressible filters for runtime debug spam (#403)
* fix(logging): route progress bars through the console writer (no more torn console)
PR #402 moved console log emit onto a dedicated writer thread, but BarGoLink
still printf()+fflush()ed its progress bars straight to stdout on the
loading/world thread. Two unsynchronized writers on one stdout made the
"=== N%" bars and the writer thread's log lines interleave character-by-
character -> the torn live console. The file log was unaffected (the bar never
writes to the file and file writes are m_fileMtx-serialized). The race also
recurs at runtime via .reload/.ahbot/playerbot commands that step bars on the
world thread while the writer is live, so a writer-start-timing fix alone is
insufficient.
Make stdout single-owner: the bar now builds one full redraw string and hands
it to the writer as a single atomic "raw" record (verbatim - no time prefix,
no color, no appended newline), so bar redraws and log lines flow through one
FIFO in program order, exactly as before the writer existed.
- ProgressBarRender.h (new): pure, dependency-free byte builders, byte-identical
to the legacy printf sequences (offline unit test, incl. an n>indic_len guard).
- ProgressBar.{h,cpp}: init/step/dtor build one string and emit via a swappable
sink; the default sink is a synchronous fwrite(stdout)+fflush, so offline tools
and realmd stay byte-for-byte unchanged.
- Log.{h,cpp}: ConsoleEmitRaw() enqueues a raw record when the writer runs, else
writes verbatim synchronously. ConsoleLogRecord gains isRaw.
- ConsoleLogWriter.cpp: Emit honours isRaw (verbatim, no '\n'); the queue-full
drop notice gets a leading '\n' so it can no longer land mid-bar.
- mangosd.cpp: install the async bar sink right after StartConsoleThread().
Colored output (including the ScriptDev banner) is untouched - only the bar,
which was never colored, changed path. Built clean (RelWithDebInfo, mangosd +
realmd, 0 errors) and confirmed torn-free in a live smoke test.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(logging): suppressible filters for runtime debug spam + console-writer review fixes
Two related logging improvements on top of the off-thread console writer.
1) LOG-FILTER SWEEP -- make a busy LogLevel/LogFileLevel=3 run usable.
- New filters LogFilter_GridAdd (0x100000) and LogFilter_DbScripts (0x200000);
LOG_FILTER_COUNT -> 22. ALL log filters now ship default-on (suppressed) so a
fresh level-3 run is quiet out of the box; set any LogFilter_* = 0 to restore
that category. ConfVersion bumped so stale configs get the out-of-date notice.
- Gated the highest-volume bare DEBUG_LOG/DETAIL_LOG/outString runtime lines onto
EXISTING filters (no new bits beyond the two above):
SPELL_CAST : "Holder of spell .. in use" (Unit), "Spell Effect DUMMY" x2
COMBAT : SMSG_ATTACKSTART (now logs attacker -> victim via GetGuidStr)
MAP_LOADING : grid load-content count, grid IDLE/REMOVAL + differed-unload
transitions, both vmap GetHitPosition LoS corrections,
AddPersistentState, and the startup "Active Flag" line
DB_STRICTED_CHECK: the four "Unused (> MaxPlayerLevel) level" notices
GRID_ADD : "X enters grid[x,y]"
DB_SCRIPTS : db_scripts process traces
Error variants (outError/outErrorDb) and one-time/info lines stay visible.
- Fixed a latent config-key typo: logFilterData read "LogFilter_MapLoading" but
every config ships "LogFilter_MapsLoading", so the key never bound and the
filter only worked by code default. Code now reads "LogFilter_MapsLoading".
- GridStates: corrected the mislabeled "moved to IDLE state" -> "REMOVAL state"
(IdleState::Update actually transitions to GRID_STATE_REMOVAL).
2) CONSOLE-WRITER REVIEW FIXES (adversarial review of the bar-tearing change).
- Single-owner stdout: the bar was made async, but the CLI prompt, CLI command
output (utf8print), the beep, and the loglevel-change notices still wrote to
stdout directly -- so they could overtake queued bar frames (e.g. the prompt
reprinted after .reload landing before/over the bar). All now route through
Log::ConsoleEmitRaw, so every non-log-line console write shares the one FIFO
and drains in program order. (Log::outTime's printf is dead -- no callers.)
- ProgressBarRender.h: include <cstddef> and use std::size_t (do not rely on
<string> to expose ::size_t globally -- non-portable on GCC/Clang).
Built clean (RelWithDebInfo, mangosd + realmd, 0 errors); filters and the .reload
prompt-ordering fix confirmed in live level-3 smoke tests.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent c718ef1 commit efabe9b
20 files changed
Lines changed: 326 additions & 101 deletions
File tree
- cmake
- src
- game
- Object
- WorldHandlers
- mangosd
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1623 | 1623 | | |
1624 | 1624 | | |
1625 | 1625 | | |
1626 | | - | |
| 1626 | + | |
1627 | 1627 | | |
1628 | 1628 | | |
1629 | 1629 | | |
| |||
2603 | 2603 | | |
2604 | 2604 | | |
2605 | 2605 | | |
2606 | | - | |
| 2606 | + | |
2607 | 2607 | | |
2608 | 2608 | | |
2609 | 2609 | | |
| |||
3047 | 3047 | | |
3048 | 3048 | | |
3049 | 3049 | | |
3050 | | - | |
| 3050 | + | |
3051 | 3051 | | |
3052 | 3052 | | |
3053 | 3053 | | |
| |||
3156 | 3156 | | |
3157 | 3157 | | |
3158 | 3158 | | |
3159 | | - | |
| 3159 | + | |
3160 | 3160 | | |
3161 | 3161 | | |
3162 | 3162 | | |
| |||
3273 | 3273 | | |
3274 | 3274 | | |
3275 | 3275 | | |
3276 | | - | |
| 3276 | + | |
3277 | 3277 | | |
3278 | 3278 | | |
3279 | 3279 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3088 | 3088 | | |
3089 | 3089 | | |
3090 | 3090 | | |
3091 | | - | |
| 3091 | + | |
3092 | 3092 | | |
3093 | 3093 | | |
3094 | 3094 | | |
| |||
4790 | 4790 | | |
4791 | 4791 | | |
4792 | 4792 | | |
4793 | | - | |
| 4793 | + | |
4794 | 4794 | | |
4795 | 4795 | | |
4796 | 4796 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
158 | | - | |
| 158 | + | |
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
188 | | - | |
| 188 | + | |
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
773 | 773 | | |
774 | 774 | | |
775 | 775 | | |
776 | | - | |
| 776 | + | |
777 | 777 | | |
778 | 778 | | |
779 | 779 | | |
| |||
2946 | 2946 | | |
2947 | 2947 | | |
2948 | 2948 | | |
2949 | | - | |
| 2949 | + | |
2950 | 2950 | | |
2951 | 2951 | | |
2952 | 2952 | | |
| |||
3346 | 3346 | | |
3347 | 3347 | | |
3348 | 3348 | | |
3349 | | - | |
| 3349 | + | |
3350 | 3350 | | |
3351 | 3351 | | |
3352 | 3352 | | |
| |||
3355 | 3355 | | |
3356 | 3356 | | |
3357 | 3357 | | |
3358 | | - | |
| 3358 | + | |
3359 | 3359 | | |
3360 | 3360 | | |
3361 | 3361 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
794 | 794 | | |
795 | 795 | | |
796 | 796 | | |
797 | | - | |
| 797 | + | |
798 | 798 | | |
799 | 799 | | |
800 | 800 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
405 | 405 | | |
406 | 406 | | |
407 | 407 | | |
408 | | - | |
| 408 | + | |
409 | 409 | | |
410 | 410 | | |
411 | 411 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1374 | 1374 | | |
1375 | 1375 | | |
1376 | 1376 | | |
1377 | | - | |
| 1377 | + | |
1378 | 1378 | | |
1379 | 1379 | | |
1380 | 1380 | | |
| |||
2159 | 2159 | | |
2160 | 2160 | | |
2161 | 2161 | | |
2162 | | - | |
| 2162 | + | |
2163 | 2163 | | |
2164 | 2164 | | |
2165 | 2165 | | |
2166 | 2166 | | |
2167 | | - | |
| 2167 | + | |
2168 | 2168 | | |
2169 | 2169 | | |
2170 | 2170 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
210 | | - | |
| 210 | + | |
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
| |||
3119 | 3119 | | |
3120 | 3120 | | |
3121 | 3121 | | |
3122 | | - | |
| 3122 | + | |
3123 | 3123 | | |
3124 | 3124 | | |
3125 | 3125 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
44 | | - | |
45 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
46 | 50 | | |
47 | 51 | | |
48 | 52 | | |
| |||
78 | 82 | | |
79 | 83 | | |
80 | 84 | | |
81 | | - | |
| 85 | + | |
82 | 86 | | |
83 | 87 | | |
84 | 88 | | |
| |||
0 commit comments