import logging, time, random
from pathlib import Path

def setup_logger():
    Path("out/logs").mkdir(parents=True, exist_ok=True)
    logging.basicConfig(
        filename="out/logs/run.log",
        level=logging.INFO,
        format="%(asctime)s %(levelname)s %(message)s"
    )
    console = logging.StreamHandler()
    console.setLevel(logging.INFO)
    formatter = logging.Formatter("%(levelname)s %(message)s")
    console.setFormatter(formatter)
    logging.getLogger().addHandler(console)

def jitter(min_ms: int, max_ms: int):
    t = random.randint(min_ms, max_ms) / 1000.0
    time.sleep(t)
