22 lines
456 B
Python
22 lines
456 B
Python
# logger.py
|
|
import logging
|
|
import os
|
|
|
|
log_dir = os.path.dirname(__file__)
|
|
os.makedirs(log_dir, exist_ok=True)
|
|
|
|
log_file = os.path.join(log_dir, "ecs_actions.log")
|
|
|
|
logging.basicConfig(
|
|
filename=log_file,
|
|
level=logging.INFO,
|
|
format='%(asctime)s - %(levelname)s - %(message)s',
|
|
encoding='utf-8'
|
|
)
|
|
|
|
def log_action(message):
|
|
if "❌" in message or "错误" in message:
|
|
logging.error(message)
|
|
else:
|
|
logging.info(message)
|