28 lines
730 B
Python
28 lines
730 B
Python
import logging
|
|
from pathlib import Path
|
|
from datetime import datetime
|
|
from config import LOG_FOLDER
|
|
|
|
|
|
def setup_logging():
|
|
logs_dir = Path(LOG_FOLDER)
|
|
logs_dir.mkdir(exist_ok=True)
|
|
|
|
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S_%f")[:-3]
|
|
log_filename = logs_dir / f"polymarket_hft_{timestamp}.log"
|
|
|
|
log_format = "%(asctime)s.%(msecs)03d - %(name)s - %(levelname)s - %(message)s"
|
|
date_format = "%Y-%m-%d %H:%M:%S"
|
|
|
|
logging.basicConfig(
|
|
level=logging.INFO,
|
|
format=log_format,
|
|
datefmt=date_format,
|
|
handlers=[
|
|
logging.FileHandler(log_filename, encoding="utf-8"),
|
|
logging.StreamHandler(),
|
|
],
|
|
)
|
|
|
|
return logging.getLogger(__name__)
|