import logging
from collections.abc import Callable
from typing import Any

logger = logging.getLogger("polkadot")
if not logger.handlers:
    logging.basicConfig(level=logging.WARNING)


def log_operation(
    fn: Callable[..., Any],
    path: str,
    fnargs: tuple[Any, ...],
    fnkwargs: dict[str, Any],
) -> None:
    """
    simple function that prints arguments passed into ``polkadot.operations.filer``

    :param fn: operation function that is decorated by filer
    :param path: path of the destination file
    :param fnargs: positional arguments passed to the decorated function
    :param fnkwargs: keyword arguments passed to the decorated function
    """
    params = ", ".join(
        [
            *[repr(path)],
            *(repr(f) for f in fnargs),
            *[f"{k} = {v!r}" for k, v in fnkwargs.items()],
        ]
    )

    logger.info(f"{fn.__module__}.{fn.__name__}({params})")
