import logging import os from datetime import datetime logging.basicConfig(format='%(asctime)s %(levelname)s - %(message)s') logger = logging.getLogger(__name__) logger.setLevel(level=logging.INFO) def current_time(): return datetime.now().astimezone().strftime('%Y-%m-%d %H:%M:%S %z') def current_date(): return datetime.now().astimezone().strftime('%Y-%m-%d') def ensure_dir(file): directory = os.path.abspath(os.path.dirname(file)) if not os.path.exists(directory): os.makedirs(directory) def write_text(file: str, text: str): ensure_dir(file) with open(file, mode='w') as f: f.write(text)