import logging
from pathlib import Path


def make_output_path(input_path: Path, postfix: str, extension: str = ".wav") -> Path:
    """Create an output path by appending a postfix to the input filename.

    e.g. make_output_path(Path("song.wav"), "eqmatched") -> Path("song_eqmatched.wav")
    """
    return input_path.parent / f"{input_path.stem}_{postfix}{extension}"


def make_stem_dir(user_audio: Path) -> Path:
    """Create and return a directory for stems alongside the user audio.

    e.g. for song.wav -> creates song_stems/ in the same directory.
    """
    stem_dir = user_audio.parent / f"{user_audio.stem}_stems"
    stem_dir.mkdir(parents=True, exist_ok=True)
    return stem_dir


def setup_logging(verbose: bool = False) -> None:
    """Configure Python logging for the application."""
    level = logging.DEBUG if verbose else logging.INFO
    logging.basicConfig(
        level=level,
        format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
        datefmt="%H:%M:%S",
    )
