semuconsulting / pyrtcm

Python library for parsing RTCM 3 protocol messages.
BSD 3-Clause "New" or "Revised" License
75 stars 23 forks source link

pyrtcm RTCMReader calls cause duplicate logging #12

Closed kmhallen closed 2 years ago

kmhallen commented 2 years ago

Describe the bug

pyrtcm version 0.3.0

Any pyrtcm.RTCMReader calls cause a functioning unrelated logger to duplicate messages in multiple formats.

To Reproduce

Execute the following minimal code:

#!/usr/bin/env python3
import sys
import logging
from pyrtcm import RTCMReader

def main() -> int:
    # Setup logging
    logger = logging.getLogger('foobar')
    logger.setLevel('DEBUG')
    formatter = logging.Formatter('%(asctime)s - %(levelname)s - foobar - %(message)s')
    ch = logging.StreamHandler()
    ch.setFormatter(formatter)
    logger.addHandler(ch)

    logger.info("This message only once")
    logger.info("This message only once again")

    RTCMReader.parse(b"\xd3\x00\x13>\xd0\x00\x03\x8aX\xd9I<\x87/4\x10\x9d\x07\xd6\xafH Z\xd7\xf7")

    logger.info("This message multiple times")
    logger.info("This message multiple times again")

    return 0

if __name__ == "__main__":
    sys.exit(main())

Expected Behaviour

Expected output:

2022-10-26 17:16:32,264 - INFO - foobar - This message only once
2022-10-26 17:16:32,264 - INFO - foobar - This message only once again
2022-10-26 17:16:32,264 - INFO - foobar - This message multiple times
2022-10-26 17:16:32,265 - INFO - foobar - This message multiple times again

Actual output:

2022-10-26 17:16:32,264 - INFO - foobar - This message only once
2022-10-26 17:16:32,264 - INFO - foobar - This message only once again
2022-10-26 17:16:32,264 - INFO - foobar - This message multiple times
2022-10-26 17:16:32,264 [INFO] main: This message multiple times
2022-10-26 17:16:32,265 - INFO - foobar - This message multiple times again
2022-10-26 17:16:32,265 [INFO] main: This message multiple times again