Skip to content

Enhance logging tests and refactor log handling#333

Merged
ppinchuk merged 16 commits intomainfrom
pp/log_unit_tests
Nov 15, 2025
Merged

Enhance logging tests and refactor log handling#333
ppinchuk merged 16 commits intomainfrom
pp/log_unit_tests

Conversation

@ppinchuk
Copy link
Collaborator

@ppinchuk ppinchuk commented Nov 9, 2025

Pull Request Overview

Improve test coverage for the JSON exception file handler and refactor log record creation in tests. Introduce a configurable sleep duration for async log flushing to enhance performance and maintainability.

…s_logs.py to ensure _JsonExceptionFileHandler leaves pre-existing JSON content untouched while appending new exception entries.
…ies_logs.py to verify _JsonExceptionFileHandler.emit short-circuits cleanly when json.dumps raises TypeError, leaving the existing JSON file untouched.
…sonExceptionFileHandler recovers gracefully when the file contains invalid JSON, replacing it with valid content for the new record
…ileHandler behavior: the JSON output groups entries by module name. The test now checks the test_utilities_logs bucket, confirms the ValueError entry was recorded, and asserts the taskName matches the async task name.
…th a docstring in logs.py and replaced the hardcoded sleep values in __aexit__.
…Log.ASYNC_EXIT_SLEEP_SECONDS = 0.01 (restored afterward) so the test completes quickly.
Copilot AI review requested due to automatic review settings November 9, 2025 00:26
@ppinchuk ppinchuk requested a review from castelao as a code owner November 9, 2025 00:26
@ppinchuk ppinchuk self-assigned this Nov 9, 2025
@ppinchuk ppinchuk added enhancement Update to logic or general code improvements p-medium Priority: medium topic-python-general Issues/pull requests related to python labels Nov 9, 2025
@ppinchuk ppinchuk added this to the Finishing touches for OSS milestone Nov 9, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the logging test suite by adding comprehensive test coverage for COMPASS Ordinance logging utilities and introduces a configurable sleep constant to improve test performance.

  • Adds ASYNC_EXIT_SLEEP_SECONDS constant to LocationFileLog class for configurable async exit sleep timing
  • Introduces extensive test coverage for logging filters, formatters, handlers, and context managers
  • Implements a test fixture to speed up async tests by reducing sleep times

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
compass/utilities/logs.py Adds configurable ASYNC_EXIT_SLEEP_SECONDS constant to enable faster testing of async exit behavior
tests/python/unit/utilities/test_utilities_logs.py Adds comprehensive test coverage for logging components including filters, formatters, handlers, and context managers; introduces fixture to accelerate async tests

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@castelao castelao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding all these tests. The operations system I'm developing relies on the logs, so it is great to know that we can count on a robust logging.

@ppinchuk ppinchuk merged commit 7a93eb7 into main Nov 15, 2025
19 checks passed
@ppinchuk ppinchuk deleted the pp/log_unit_tests branch November 15, 2025 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Update to logic or general code improvements p-medium Priority: medium topic-python-general Issues/pull requests related to python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants