Preserve tested Verify source, authoritative READY checks, bounded bridge retries, diagnostics and failure-only reporting. Include 336-test suite and packaging assets; exclude live Mentor samples, field logs, backups and distributions.
34 lines
2.0 KiB
Python
34 lines
2.0 KiB
Python
from pathlib import Path
|
|
import sys
|
|
import hashlib
|
|
|
|
def configure(root: Path):
|
|
try:
|
|
from dx_productivity.trial_task_center.logging_setup import configure_logging, install_exception_hooks
|
|
context = configure_logging(root); install_exception_hooks(context)
|
|
# Reuse the mature rotating/UTC logger implementation, but keep product identity CBB-specific.
|
|
context.logger.name = "cbb_refresh_verify." + hashlib.sha256(str(root.resolve()).encode("utf-8")).hexdigest()[:16]
|
|
context.logger.info("cbb_logging_configured root=%s application_log=%s", context.root, context.application_log_path)
|
|
for handler in context.logger.handlers: handler.flush()
|
|
return context
|
|
except ImportError:
|
|
import logging
|
|
from logging.handlers import RotatingFileHandler
|
|
root.mkdir(parents=True, exist_ok=True); (root/'logs').mkdir(exist_ok=True)
|
|
logger=logging.getLogger('cbb_refresh_verify'); logger.handlers.clear(); logger.setLevel(logging.INFO)
|
|
# Keep the standalone fallback bounded as well. The packaged build
|
|
# normally uses the replacement tool's rotating logger, but a target
|
|
# machine may intentionally omit that optional dependency.
|
|
logger.addHandler(RotatingFileHandler(
|
|
root/'logs'/'application.log', maxBytes=10 * 1024 * 1024,
|
|
backupCount=5, encoding='utf-8'))
|
|
return type('Context',(),{'root':root,'logger':logger,'application_log_path':root/'logs'/'application.log'})()
|
|
|
|
def capture(context, *, operation, returncode, stdout, stderr):
|
|
try:
|
|
from dx_productivity.trial_task_center.logging_setup import capture_subprocess_output
|
|
capture_subprocess_output(context, operation=operation, returncode=returncode, stdout=stdout, stderr=stderr)
|
|
except ImportError:
|
|
context.logger.info('operation=%s returncode=%s stdout=%s stderr=%s', operation, returncode, stdout.rstrip(), stderr.rstrip())
|
|
for handler in context.logger.handlers: handler.flush()
|