"""Logging utilities for NFOguard""" from datetime import datetime, timezone import os def _get_local_timezone(): """Get the local timezone, respecting TZ environment variable""" tz_name = os.environ.get('TZ', 'UTC') try: # Try zoneinfo first (Python 3.9+) from zoneinfo import ZoneInfo return ZoneInfo(tz_name) except ImportError: # Fallback for older Python versions try: import pytz return pytz.timezone(tz_name) except: # Final fallback to UTC return timezone.utc except: # If zone name is invalid, fallback to UTC return timezone.utc def _log(level: str, msg: str): """Basic logging function that writes to console""" tz = _get_local_timezone() print(f"[{datetime.now(tz).isoformat(timespec='seconds')}] {level}: {msg}")