Skip to content

Conversation

@nchapman
Copy link
Collaborator

Needed to help track down crashes across our various C binaries.

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.
Copilot AI review requested due to automatic review settings December 11, 2025 06:14
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() and log_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_FILE environment 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.

@nchapman nchapman force-pushed the feature/bulletproof-logs branch from 072296f to 48bc51e Compare December 11, 2025 06:34
@nchapman nchapman merged commit 8686761 into develop Dec 11, 2025
4 checks passed
@nchapman nchapman deleted the feature/bulletproof-logs branch December 11, 2025 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants