Console Output and Logging
Relevant source files
The following files were used as context for generating this wiki page:
The Console Output and Logging system in the safe64switch project provides real-time feedback to the user during the migration process from 32-bit to 64-bit kernels on Raspberry Pi devices. It serves to inform the operator of the script's progress, hardware validation results, and the status of critical file operations such as configuration backups and modifications.
This system is primarily implemented through standard output streams within the shell environment, ensuring that users are aware of the success or failure of specific steps, such as hardware detection and the application of performance settings.
Sources: safe64.sh:1-32, README.md:1-15
Script Execution Feedback
The script utilizes the echo command to provide a step-by-step trace of its execution. This allows the user to monitor the automation process as it interacts with the system's firmware configuration.
Progress Milestones
The logging flow follows a linear progression, announcing the start of the script, the status of hardware verification, and the completion of configuration changes.
| Message Category | Description | Source File Reference |
|---|---|---|
| Initialization | Announces the start of the safe64.sh script execution. | safe64.sh:9 |
| Progress | Updates on file backups and kernel enablement status. | safe64.sh:18-24 |
| Completion | Final instructions to the user regarding system reboot. | safe64.sh:31-32 |
Sources: safe64.sh:9-32
Process Flow Diagram
The following diagram illustrates how console output is interspersed with the script's logic to provide a transparent execution state.
The diagram shows the sequential integration of log messages within the script's decision-making branches.
Sources: safe64.sh:8-32
Error Reporting and Termination
The logging system distinguishes between informational messages and critical errors. Error handling is coupled with script termination to prevent unsafe operations on unsupported hardware.
Hardware Validation Failures
If the script detects that it is not running on a Raspberry Pi device by inspecting /proc/device-tree/model, it outputs a specific error message to the console before exiting with a non-zero status code.
- Error String:
Error: Not running on a Raspberry Pi. Exiting. - Exit Code:
1
Sources: safe64.sh:12-15
Exit on Error (set -e)
The script uses the set -e directive, which ensures that if any command fails (returns a non-zero exit code), the script terminates immediately. While this does not produce a custom log message for every possible failure, it prevents the console from being flooded with subsequent errors if a primary operation like cp or echo fails.
Sources: safe64.sh:7
Summary of Logged Events
| Event | Console Output Message | Context |
|---|---|---|
| Script Launch | Starting safe64.sh script... | Triggered at the beginning of execution. |
| Filesystem Backup | Backing up /boot/config.txt to /boot/config.txt.bak | Occurs before any modifications. |
| Kernel Modification | Enabling 64-bit kernel... | Only shown if arm_64bit=1 is missing. |
| Redundant Action | 64-bit kernel already enabled. | Shown if the setting is already present. |
| Optimization | Adding performance settings... | Indicates addition of gpu_mem settings. |
| Finalization | Done. | Indicates script reached the end of the logic. |
Sources: safe64.sh:9-32
The Console Output and Logging mechanism in safe64switch is a lightweight, synchronous reporting system designed to guide users through a critical system configuration change while ensuring safety through immediate error reporting.