~kf5jwc/sms-printer

3978baa20d6308b06d5668f55d0c77ce4586a52a — Kyle Jones 1 year, 4 months ago fac951b v0.2.2
Improved logging around current parser
2 files changed, 5 insertions(+), 3 deletions(-)

M pyproject.toml
M sms_printer/printer.py
M pyproject.toml => pyproject.toml +1 -1
@@ 5,7 5,7 @@ build-backend = "poetry.masonry.api"
[tool.poetry]
name = "sms-printer"
description = "An SMS printer library"
version = "0.2.1"
version = "0.2.2"
license = "GPL-2.0"
authors = ["Kyle Jones <kyle@kf5jwc.us>"]


M sms_printer/printer.py => sms_printer/printer.py +4 -2
@@ 12,18 12,20 @@ def parse_messages(data: str) -> List:
    parsers = [parser for parser in PARSERS if parser.validate(data)]
    logger.trace("Parsers for this mesage:")
    [logger.trace("{}", repr(parser)) for parser in parsers]
    logger.info("Parsers found for this message: {}", len(parsers))
    logger.debug("Parsers found for this message: {}", len(parsers))

    if not len(parsers):
        raise NoValidParserForMessage

    for parser in parsers:
        try:
            logger.debug("Parsing message with parser: {}", parser.__name__)
            messages = parser.parse(data)
        except Exception as e:
            logger.trace("Parser encountered error while parsing message: {}", parser)
            logger.debug("Parser failed")
            logger.trace("Exception: {}", e)
        else:
            logger.debug("Parser succeeded")
            return messages

    raise NoParserForMessage