mirror of
https://github.com/nubenetes/awesome-kubernetes.git
synced 2026-08-19 04:16:26 +00:00
fix: harden logging infrastructure to prevent duplicate logs
- Implemented manual sys.stdout.flush() in log_event. - Enabled flush=True for all print statements in the logger. - Set PYTHONUNBUFFERED: '1' in the V2 Builder workflow environment. - These changes ensure immediate log delivery and reduce GHA agent stuttering.
This commit is contained in:
@@ -74,6 +74,7 @@ jobs:
|
||||
FORCE_EVAL: ${{ github.event.inputs.force_reevaluate || 'false' }}
|
||||
ENRICH_METADATA: ${{ github.event.inputs.enrich_metadata || 'false' }}
|
||||
PYTHONPATH: .
|
||||
PYTHONUNBUFFERED: "1"
|
||||
run: |
|
||||
python -u src/v2_optimizer.py
|
||||
if [ -f v2_safety_report.md ]; then
|
||||
|
||||
+6
-2
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
import sys
|
||||
from datetime import datetime
|
||||
|
||||
# Ruta por defecto para el log local (fuera del repo)
|
||||
@@ -14,11 +15,14 @@ def log_event(message: str, section_break: bool = False):
|
||||
|
||||
if section_break:
|
||||
separator = "=" * 60
|
||||
print(f"\n{separator}\n{formatted_msg}\n{separator}")
|
||||
print(f"\n{separator}\n{formatted_msg}\n{separator}", flush=True)
|
||||
_write_to_file(f"\n{separator}\n{formatted_msg}\n{separator}")
|
||||
else:
|
||||
print(formatted_msg)
|
||||
print(formatted_msg, flush=True)
|
||||
_write_to_file(formatted_msg)
|
||||
|
||||
# Mandate 13: Ensure immediate visibility and prevent GHA agent stuttering
|
||||
sys.stdout.flush()
|
||||
|
||||
def _write_to_file(message: str):
|
||||
# Only try to write to file if not in GitHub Actions
|
||||
|
||||
Reference in New Issue
Block a user