Example #1
0
def logger_zero_verbosity_logs_error_test(caplog):
    """Test that zero verbosity logs error messages.

    Parameters
    ----------
    caplog : CapLog
        Pytest capture log. Provided automatically by PyTest.
    """
    configure_root_logger(verbosity=0, debug=False)
    log = getLogger()
    log.error("Testing error message")

    assert len(caplog.records) == 1
Example #2
0
def logger_three_verbosity_logs_debug_test(caplog):
    """Test that three verbosity (-vvv) logs debug messages.

    Parameters
    ----------
    caplog : CapLog
        Pytest capture log. Provided automatically by PyTest.
    """
    configure_root_logger(verbosity=3, debug=False)
    log = getLogger()

    log.debug("Debug")
    assert len(caplog.records) == 1
Example #3
0
def logger_three_verbosity_still_logs_warnings_test(caplog):
    """Test that three verbosity (-vvv) still logs errors messages.

    Parameters
    ----------
    caplog : CapLog
        Pytest capture log. Provided automatically by PyTest.
    """
    configure_root_logger(verbosity=3, debug=False)
    log = getLogger()

    log.warning("Warning")
    assert len(caplog.records) == 1
Example #4
0
def logger_two_verbosity_logs_info_test(caplog):
    """Test that two verbosity (-vv) logs info messages.

    Parameters
    ----------
    caplog : CapLog
        Pytest capture log. Provided automatically by PyTest.
    """
    configure_root_logger(verbosity=2, debug=False)
    log = getLogger()

    log.info("Info")
    assert len(caplog.records) == 1
Example #5
0
def logger_one_verbosity_still_logs_errors_test(caplog):
    """Test that one verbosity (-v) still logs error messages.

    Parameters
    ----------
    caplog : CapLog
        Pytest capture log. Provided automatically by PyTest.
    """
    configure_root_logger(verbosity=1, debug=False)
    log = getLogger()

    log.error("Error")
    assert len(caplog.records) == 1
Example #6
0
def logger_one_verbosity_logs_warnings_test(caplog):
    """Test that one verbosity (-v) logs warning messages.

    Parameters
    ----------
    caplog : CapLog
        Pytest capture log. Provided automatically by PyTest.
    """
    configure_root_logger(verbosity=1, debug=False)
    log = getLogger()

    log.warning("Test warning message")
    assert len(caplog.records) == 1
Example #7
0
def logger_zero_verbosity_does_not_log_debug_test(caplog):
    """Test that zero verbosity does NOT log debug messages.

    Parameters
    ----------
    caplog : CapLog
        Pytest capture log. Provided automatically by PyTest.
    """
    configure_root_logger(verbosity=0, debug=False)
    log = getLogger()

    log.debug("Test debug message")

    assert len(caplog.records) == 0
Example #8
0
 def __init__(self, capture_filepath: PathLikeOrString, logger: Logger = getLogger()):
     super().__init__(capture_filepath, logger=logger)
Example #9
0
    def __init__(self, log: Optional[LoggerType] = None):
        self.log = log if log else getLogger()
        object.__setattr__(THIS, "help", self())
        object.__setattr__(THIS, "__help__", self())

        pass
Example #10
0
# from src.poretitioner.utils import *
# from src.poretitioner.utils.classify import *
# from src.poretitioner.utils.configuration import (
#     GeneralConfiguration,
#     SegmentConfiguration,
#     readconfig,
# )

LOG_VERBOSITY = 3
# Temporarily changing the logger format for the intro messages.
temp_logger_format = "%(log_color)s%(message)s"
logger.configure_root_logger(verbosity=LOG_VERBOSITY,
                             debug=True,
                             format=temp_logger_format)

log = logger.getLogger()

THIS = __import__(__name__)  # The currently running module

log.debug(f"=============~ Poretitioner ~============\n")


def do_intro(log: LoggerType):
    log.debug(f"\nHi there, my name is Jessica!")
    log.info(f"And my name is Katie!")

    log.debug(f"\nWelcome to the Poretitioner Playground")
    log.debug(
        f"\nThis is a fun, interactive python REPL environment for learning about, testing, and hacking the Poretitioner."
    )
    log.debug(