24 lines
544 B
Python
24 lines
544 B
Python
|
|
from pathlib import Path
|
|
from datetime import datetime
|
|
import logging
|
|
|
|
# Create logs folder if it doesn't exist
|
|
Path("logs").mkdir(exist_ok=True)
|
|
|
|
# Daily log file
|
|
log_file = Path("logs") / f"etl_{datetime.now():%Y%m%d}.log"
|
|
|
|
# Configure logging
|
|
logging.basicConfig(
|
|
level=logging.INFO,
|
|
format="%(asctime)s | %(levelname)-8s | %(message)s",
|
|
datefmt="%Y-%m-%d %H:%M:%S",
|
|
handlers=[
|
|
logging.StreamHandler(),
|
|
logging.FileHandler(log_file, encoding="utf-8"),
|
|
],
|
|
)
|
|
|
|
# Export logger
|
|
log = logging.getLogger("etl") |