One function
add_file_handler in colcon/colcon-core
The author described this change as “Fix modified logger in add_file_handler, add tests (#649)”. It counts as a record because the check below fails on the code as it stood at b17460865 and passes on a067589eb, with nothing else changed between the two runs.
Projectcolcon/colcon-core
Fix saved2024-05-24
Sharing licenceApache-2.0 · LICENSE
Change size+5 −5
What the code was meant to do, written into the code itself as a docstring
Add a file handler to the logger which logs messages of all levels. :param logger: The logger to add the file handler to :param path: The path of the generated log file :returns: The added file handler :rtype: logging.FileHandler
The change
| 27 | 27 | if isinstance(handler, logging.StreamHandler): | |
| 28 | 28 | formatter = handler.formatter | |
| 29 | 29 | # filter colcon specific log messages from default stream handler | |
| 30 | - | handler.addFilter(Filter(colcon_logger.name)) | |
| 30 | + | handler.addFilter(Filter(logger.name)) | |
| 31 | 31 | ||
| 32 | 32 | # add a stream handler replacing the one filtered on the root logger | |
| 33 | 33 | handler = logging.StreamHandler() | |
| 34 | 34 | if formatter: | |
| 35 | 35 | # use same formatter as for stream handler | |
| 36 | 36 | handler.setFormatter(formatter) | |
| 37 | - | handler.setLevel(colcon_logger.getEffectiveLevel()) | |
| 38 | - | colcon_logger.addHandler(handler) | |
| 37 | + | handler.setLevel(logger.getEffectiveLevel()) | |
| 38 | + | logger.addHandler(handler) | |
| 39 | 39 | ||
| 40 | 40 | # add a file handler writing all log levels | |
| 41 | 41 | handler = logging.FileHandler(str(path)) | |
| ⋯ | |||
| 53 | 53 | # use same formatter as for stream handler | |
| 54 | 54 | handler.setFormatter(formatter) | |
| 55 | 55 | handler.setLevel(1) | |
| 56 | - | colcon_logger.addHandler(handler) | |
| 56 | + | logger.addHandler(handler) | |
| 57 | 57 | ||
| 58 | 58 | # change the logger to handle all levels | |
| 59 | - | colcon_logger.setLevel(1) | |
| 59 | + | logger.setLevel(1) | |
| 60 | 60 | ||
| 61 | 61 | return handler | |
The check that tells the two apart
fail→pass·test/test_logging.py::test_add_file_handler
Check file test/test_logging.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before itb174608650a3521203e10d7950aa35a3c6d63dcc
Broken version dated2024-05-24
Modulecolcon_core.logging
Units changedadd_file_handler
Fingerprint6de85c38ed94d078
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.