Native logging that's more reliable#68
Merged
Merged
Conversation
Replace shell redirect logging with native file logging for better crash debugging. C binaries now use LOG_FILE env var to write logs directly, with optional LOG_SYNC=1 for fsync after each write.
Adds LOG_debug calls through the initialization of minui, minarch, and shui to help diagnose boot crashes. Also fixes shui to log to its own file (shui.log) instead of inheriting minui.log.
There was a problem hiding this comment.
Pull request overview
This pull request adds comprehensive native logging infrastructure to help track down crashes in C binaries across various platforms. The changes introduce a new global logging API that uses environment variables (LOG_FILE and LOG_SYNC) to configure file-based logging with optional crash-safe synchronization.
Key changes:
- Implements
log_open()andlog_close()API for global logging initialization with environment variable support - Adds signal handlers (SIGTERM/SIGINT) to keymon daemons for clean shutdown and proper log flushing
- Updates platform init scripts to set
LOG_FILEenvironment variable for keymon - Adds extensive debug logging throughout minarch and shui for initialization tracking
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| workspace/all/common/log.h | Adds global logging API documentation (log_open, log_close, log_sync, log_is_file_open) with environment variable support |
| workspace/all/common/log.c | Implements global logging with LOG_FILE/LOG_SYNC environment variables, thread-safe file operations, and crash-safe sync mode |
| workspace/all/utils/keymon/keymon.c | Adds signal handling for clean shutdown, integrates log_open/log_close, changes main loop to respect running flag |
| workspace/miyoomini/keymon/keymon.c | Adds signal handling and integrates log_open/log_close with proper cleanup in quit() |
| workspace/all/minui/minui.c | Initializes logging early in main(), calls log_close() on all exit paths |
| workspace/all/minarch/minarch.c | Initializes logging early, adds extensive debug logging for initialization steps, closes log on exit |
| workspace/all/utils/shui/shui.c | Initializes logging in daemon mode, adds debug logging throughout daemon lifecycle, closes log on exit |
| workspace/all/paks/MinUI/platforms/*/init.sh | Updates keymon launch to use LOG_FILE environment variable instead of shell redirection (11 platform files) |
| workspace/all/paks/MinUI/platforms/my355/init.sh | Removes shell redirection (2>&1) in favor of native logging |
| workspace/all/paks/MinUI/launch.sh.template | Adds documentation for LOG_FILE/LOG_SYNC, updates binary launches to use LOG_FILE, renames shell log from minui.log to shell.log |
| tests/unit/all/common/test_log.c | Adds 16 comprehensive test cases for global logging API covering environment variables, reopening, sync mode, and log routing |
| makefile.qa | Enables INFO and DEBUG logs for log tests to validate all log levels |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
072296f to
48bc51e
Compare
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.
Needed to help track down crashes across our various C binaries.