Repository navigation
Add client logger - #17
Conversation
84ae39a to
7725658
Compare
|
I'm burning through copilot tokens on this first day of the month, but I'm considering building this on top of spdlog. Response from copilot:
|
|
I'm not sure if integrating spdlog is worth the cost of time and/or tokens at the moment, but this branch needs some work to at least be on par with cc_logger. I had put some effort into the cc_logger formatting (approximating that of the python rich logger), but copilot does not appear to have copied much or any of that over (e.g. no use of color). I updated quicklogger to use the logger, which would eliminate the need for the DEBUG_TEXT message. |
|
I did some more iteration with copilot to bring this up to feature parity with cc_logger and fix some issues it found. Some fixes are likely overkill but could avoid future problems (e.g. loggers in multiple threads). |
commit was revised to fix copilot's whitespace (CRLF) mangling
Allow console output stream to be configured (defaults to stderr) Allow colorized output to be disabled, including automatically when not outputting to a terminal Add RTMA_LevelName and RTMA_LevelFromName functions Fix log file name format
**Logger changes** (in `RTMA_Logger.cpp` and `RTMA_Logger.h`) - **Locking:** every getter and setter now takes the mutex, and `GetLogName()` no longer deadlocks when `LogMessage` calls it. - **File sink:** the file stays open, and a byte counter drives rotation at 3 MiB with three backups. I flush after every line. If the file can't be opened, written, or reopened after rotating, the sink turns itself off and prints one warning on the console stream. - **RTMA send:** the payload is built under the lock but sent after releasing it. A per-thread guard stops a log call made during a send from sending again. A thrown send turns the RTMA sink off. - **Dangling module:** `RTMA_Module`'s destructor calls a new `Detach()`, so a `Child()` logger that outlives the module no longer touches freed memory. It still logs to console and file. - **Truncation:** only the RTMA payload is cut at 1023 characters. Console and file get the full message. - **Time:** `MDF_RTMA_LOG.time` is now epoch seconds, taken once per call and shared with the console and file timestamps. - **Windows color:** in AUTO mode the logger turns on virtual terminal processing once for the console stream, and skips color if that fails. **Docs:** `RTMA.h` now says `RTMA_Module` and `SendMessage` are not thread-safe, and that logging to RTMA from several threads needs `Logger().SetRTMAEnabled(false)`. **Tests:** `public_api_test.cpp` gained four cases: - a child logger outliving its module; - rotation over 11 MB, leaving `.1` to `.3` but no `.4`; - a 2000-character message arriving whole with no escape codes; - a short multi-threaded logging run. `CMakeLists.txt` links `Threads::Threads` into the test.
Port the pyrtma client logger to the c++ rtma library, deprecating the external cc_logger library. Written with github copilot (GPT-5.6-terra).
Stack created with GitHub Stacks CLI • Give Feedback 💬