from pathlib import Path

import pytest
from loguru import logger

from libretime_shared.logging import (
    create_task_logger,
    level_from_verbosity,
    setup_logger,
)


@pytest.mark.parametrize(
    "verbosity,level_name,level_no",
    [
        (-100, "error", 40),
        (-1, "error", 40),
        (0, "warning", 30),
        (1, "info", 20),
        (2, "debug", 10),
        (3, "trace", 5),
        (100, "trace", 5),
    ],
)
def test_level_from_verbosity(verbosity, level_name, level_no):
    level = level_from_verbosity(verbosity)
    assert level.name == level_name
    assert level.no == level_no


def test_setup_logger(tmp_path: Path):
    log_filepath = tmp_path / "test.log"
    extra_log_filepath = tmp_path / "extra.log"

    setup_logger(1, log_filepath)

    extra_logger = create_task_logger(2, extra_log_filepath, True)

    logger.info("test info")
    extra_logger.info("extra info")
    logger.debug("test debug")

    extra_logger.complete()
    logger.complete()

    assert len(log_filepath.read_text().splitlines()) == 1
    assert len(extra_log_filepath.read_text().splitlines()) == 1

@@ -99,16 +99,37 @@
 mport (%0A
+    DEBUG,%0A    INFO,%0A
     crea
@@ -781,17 +781,20 @@
 _logger(
-1
+INFO
 , log_fi
@@ -840,17 +840,21 @@
 _logger(
-2
+DEBUG
 , extra_

fix tests