Repository navigation
Fix logs --since and /proxy/logs?since= to filter by date and time - #1996
Open
waldekmastykarz wants to merge 8 commits into
Open
waldekmastykarz wants to merge 8 commits into
waldekmastykarz wants to merge 8 commits into
Conversation
…loses dotnet#1961 Detached log lines don't start with a [hh:mm:ss.fff] timestamp, so the previous filter matched no lines, included all of them and ignored the date. Reconstruct each line's full date and time from the instance start time, request blocks' 'time' lines, debug/trace time-of-day prefixes (with midnight rollover) and JSON 'timestamp' properties, and filter on that. The log line format is unchanged. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3b2ff54c-c6ab-4c98-a477-c522a6c02ac2
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Filtering remains incorrect after hot reload, with timestamps disabled, and for buffered requests in follow mode.
3 open issues
What changed in this PR
Addresses #1961 by sharing full-date log filtering between the CLI and management API without changing the log format.
Changes:
- Reconstructs timestamps from request blocks, debug/trace prefixes, and JSON entries.
- Integrates shared filtering into both log readers.
- Adds tests for multi-day filtering, midnight rollover, and timestamp fallback.
| File | Description |
|---|---|
| DevProxy/Logging/LogSinceFilter.cs | Implements shared timestamp reconstruction and filtering. |
| DevProxy/Commands/LogsCommand.cs | Integrates filtering and changes follow-mode handling. |
| DevProxy/ApiControllers/ProxyController.cs | Uses shared filtering with process start time. |
| DevProxy.Tests/LogSinceFilterTests.cs | Covers timestamp formats and date boundaries. |
Review effort: Balanced
Preserve detached timestamps, use process start across hot reloads, share event-time filtering for CLI/API follow mode, and handle DST rollback. Add regression coverage and document detached timestamp retention. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Integrate upstream main c9a4a0b while preserving the reviewed log filtering fixes. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Include full UTC timestamps on detached regular records at every log level, preserve DateTimeOffset instants through snapshot/follow filtering, and share offset-aware CLI/API cutoff parsing. Add repeated-hour and Warning-level regressions while retaining interactive formatting. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Integrate upstream main b9865a6; complete solution build and all 494 tests pass. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Accept Normal request entries with an empty label before the closing corner. Add real-formatter regressions for snapshot timestamps and immediate plain/ANSI follow completion. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This branch has not been deployed
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.


Closes #1961
Problem
devproxy logs --sinceandGET /proxy/logs?since=assumed log lines start with[hh:mm:ss.fff]and combined that withDateTime.Today. Detached log lines don't have that prefix (e.g.info …,req ╭ GET …). Any line that didn't match was included, sosincefiltered nothing. For example,--since 2030-01-01T00:00:00returned the whole log. Even when it did match, the date was ignored.Fix
New
LogSinceFilter(shared by the CLI command and the API controller) filters full timestamp instants:req ╭ … ╰, including the preceding blank line) use the full ISO timestamp from theirtime │line.[HH:mm:ss.fffffff]prefixes (and[HH:mm:ss.fff]) are reconstructed against the previous timestamp, accounting for midnight, small out-of-order writes, and the repeated daylight-saving hour.timestampinstants.showTimestamps: false. Interactive output continues to honor that setting and keeps its existing formatting.DateTimeOffset, preserving explicit offsets and correct ordering across both occurrences of the repeated daylight-saving hour.CLI
--followand API SSE streaming share an incremental reader that filters by event time, retains timestamp reconstruction state, and buffers partial lines and incomplete request blocks across reads. Requests that start before the cutoff remain excluded even if they finish afterward.Validation
TZ=America/New_York.94a9579(Count intercepted requests for mock nth #1987).showTimestamps: falseconfirm CLI/API snapshot and follow filtering at Information and Warning levels. Newly emitted Error records remain visible after a post-start cutoff at Warning level; older records and future-cutoff output are excluded.