Provides unified logging with rotation, dual output to console and files, and asynchronous writing for AI skill modules. Use this to maintain consistent, manageable logs across background processes.
# Source: https://github.com/LeoYeAI/openclaw-master-skills | License: MIT | Copyright 2026 MyClaw.ai (LeoYeAI)
# Provided via justclaw.it.com; keep this notice with the code.
"""
IMA Skills 日志模块
提供统一的日志配置和管理
功能:
- 双输出:同时输出到控制台和文件
- 日志轮转:自动管理日志文件大小
- 分级记录:INFO(关键操作)和 ERROR(错误信息)
- 性能优化:异步写入,不影响主流程
日志文件位置:~/.openclaw/logs/ima_skills/
文件命名:ima_create_YYYYMMDD.log
保留策略:保留最近 7 天
"""
import logging
import os
from datetime import datetime
from logging.handlers import RotatingFileHandler
from pathlib import Path
def setup_logger(
name: str = "ima_skills",
log_level: int = logging.INFO,
max_bytes: int = 10 * 1024 * 1024, # 10MB
backup_count: int = 7, # Keep 7 days
console_output: bool = True,
) -> logging.Logger:
"""
配置日志系统
Args:
name: Logger 名称
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key