Repository navigation
refactor: Split log-query into focused modules (#173) - #192
Merged
Merged
Conversation
Split the 911-line log-query.ts file into a well-organized directory structure with focused, single-responsibility modules. This is PR #3 in the series of refactorings to address issue #173. ## Changes ### Directory Structure Created `source/utils/logging/log-query/` with the following organization: - `types.ts` - All type definitions - `storage/` - Storage implementation (circular buffer, indexing, main storage class) - `query/` - Query execution and filtering - `aggregation/` - Log aggregation and facet generation - `utils/` - Sorting utilities and helper functions - `index.ts` - Public API re-exports ### Modules Created **Storage** (3 modules + tests): - `circular-buffer.ts` - O(1) circular buffer for log entries - `index-manager.ts` - Efficient indexing for lookups - `log-storage.ts` - Main storage class orchestrating buffer and indexes **Query** (3 modules + tests): - `filter-predicates.ts` - Log entry filtering logic - `query-engine.ts` - Query execution engine - `query-builder.ts` - Fluent query builder API **Aggregation** (2 modules + tests): - `aggregator.ts` - Log aggregation engine - `facet-generator.ts` - Facet generation for query results **Utils** (2 modules + tests): - `sorting.ts` - Sorting utilities for log entries - `helpers.ts` - Common query helper functions ### Bug Fixes - Fixed `getLevelPriority` returning incorrect value for 'fatal' level (changed from `||` to `??` operator to handle 0 correctly) - Fixed memory threshold filter semantics in filter predicates ### Test Coverage - Added comprehensive test suites for all 12 new modules - 155 new tests added covering all functionality - All tests passing ### Breaking Changes - Import paths updated: - `./log-query.js` → `./log-query/index.js` - Removed unused exports from public API to clean up knip warnings - Deleted original `log-query.ts` and `log-query.spec.ts` files
Avtrkrb
approved these changes
Dec 21, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Split the 911-line
log-query.tsfile into a well-organized directory structure with focused, single-responsibility modules. This is PR #3 in the series of refactorings to address issue #173.Changes Made
Directory Structure
Created
source/utils/logging/log-query/with the following organization:New Modules (12 total)
Storage (3 modules + tests)
circular-buffer.ts- O(1) circular buffer for log entriesindex-manager.ts- Efficient indexing for lookupslog-storage.ts- Main storage class orchestrating buffer and indexesQuery (3 modules + tests)
filter-predicates.ts- Log entry filtering logicquery-engine.ts- Query execution enginequery-builder.ts- Fluent query builder APIAggregation (2 modules + tests)
aggregator.ts- Log aggregation enginefacet-generator.ts- Facet generation for query resultsUtils (2 modules + tests)
sorting.ts- Sorting utilities for log entrieshelpers.ts- Common query helper functionsBug Fixes
getLevelPriorityreturning incorrect value for 'fatal' level (changed from||to??operator to handle 0 correctly)Test Coverage
Breaking Changes
./log-query.js→./log-query/index.jslog-query.tsandlog-query.spec.tsfilesTest plan