Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 29, 2025

Logging configuration in cli.py only applied to the main process. Child processes spawned via multiprocessing.Process inherited only the NullHandler, suppressing all warnings and errors from parsing operations.

Changes

  • Added _configure_logging(log_level, log_file=None) helper - Configures logging handlers in any process with the same formatter and file output as the parent

  • Updated cli_parse() signature - Accepts log_level and log_file parameters, calls _configure_logging() on entry to set up logging in child process

  • Modified Process creation - Captures and passes logger.level and opts.log_file from parent to child processes

Example

Before this change, DNS warnings in child processes were invisible:

# cli_parse runs in child process - warnings silently lost
logger.warning(f"get_reverse_dns({ip_address}) exception: {e}")

After this change, all logging configuration propagates:

$ parsedmarc --warnings sample.xml
WARNING:utils.py:208:get_reverse_dns(12.20.127.122) exception: All nameservers failed...

The fix uses exact type checking (type(h) is logging.StreamHandler) to distinguish StreamHandler from FileHandler subclass, and catches specific file I/O exceptions rather than bare Exception.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 1.0.0.1
    • Triggering command: REDACTED, pid is -1 (packet block)
  • 1.1.1.1
    • Triggering command: REDACTED, pid is -1 (packet block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Logging configuration from cli.py not propagated to child parser processes</issue_title>
<issue_description>High-Level:
The log configuration in cli.py only applies to the main script, not to the child processes it creates for parsing.
The log messages from cli.py work because they are executed in the parent process before the child processes are finished.

Break Down:

  1. The Process starts, executing the cli_parse function.

  2. cli_parse calls parse_report_file (from __init__.py).

  3. parse_report_file eventually calls get_ip_address_info (from utils.py).

  4. get_ip_address_info calls your function, get_reverse_dns (from utils.py).

  5. When a dns.exception.DNSException occurs inside get_reverse_dns, it calls logger.warning(...).

  6. This logger.warning is handled by the NullHandler because the FileHandler was only configured in the parent process.
    </issue_description>

<agent_instructions>This is an old issue. I don't know if it is still a problem. Check and see if the problem still exists, and if so, open a PR to fix it.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits December 29, 2025 19:48
- Add _configure_logging() helper function to set up logging in child processes
- Modified cli_parse() to accept log_level and log_file parameters
- Pass current logging configuration from parent to child processes
- Logging warnings/errors from child processes now properly display

Fixes issue where logging handlers in parent process were not inherited by
child processes created via multiprocessing.Process(). Child processes now
configure their own logging with the same settings as the parent.

Tested with sample files and confirmed warnings from DNS exceptions in child
processes are now visible.

Co-authored-by: seanthegeek <[email protected]>
- Use exact type check (type(h) is logging.StreamHandler) instead of isinstance
  to avoid confusion with FileHandler subclass
- Catch specific exceptions (IOError, OSError, PermissionError) instead of
  bare Exception when creating FileHandler
- Kept logging.ERROR as default to maintain consistency with existing behavior

Co-authored-by: seanthegeek <[email protected]>
Copilot AI changed the title [WIP] Fix logging configuration propagation to child parser processes Fix logging configuration not propagating to child parser processes Dec 29, 2025
Copilot AI requested a review from seanthegeek December 29, 2025 19:53
@seanthegeek seanthegeek marked this pull request as ready for review December 29, 2025 19:56
@seanthegeek seanthegeek merged commit 6719a06 into master Dec 29, 2025
5 checks passed
seanthegeek added a commit that referenced this pull request Dec 29, 2025
- Fix logging configuration not propagating to child parser processes (#646).
- Update `mailsuite` dependency to `?=1.11.1` to solve issues with iCloud IMAP (#493).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Logging configuration from cli.py not propagated to child parser processes

2 participants