{{ message }}
Repository navigation
Start-Transcript: Add -IncludeTimeStamp parameter - #28230
Open
soroshsabz wants to merge 5 commits into
Open
soroshsabz wants to merge 5 commits into
soroshsabz wants to merge 5 commits into
Conversation
Add an opt-in IncludeTimeStamp switch to Start-Transcript that prefixes each transcribed line of command input and output with the time it was recorded, formatted as 'yyyy-MM-dd HH:mm:ss' using the invariant culture and local time. The timestamp is applied when output is queued to the transcript (in TranscriptionCommand/TranscribeResult via the new TranscriptionOption.AddOutput helper), so it reflects the time the output was produced rather than the time it was flushed to disk. Multi-line entries have each non-empty line prefixed. Transcript header/footer and IncludeInvocationHeader banners are left unchanged since they already contain timestamps. Without the switch, transcript output is byte-identical to before. Resolves PowerShell#24135
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Screen-scraped Windows native output receives completion-time timestamps rather than individual line-production times.
1 open issue
What changed in this PR
Adds opt-in transcript timestamps to support chronological log review, addressing #24135.
Changes:
- Exposes
Start-Transcript -IncludeTimeStamp. - Prefixes non-empty command and output lines when queued, leaving headers unchanged.
- Adds tests for timestamped output and default behavior.
Review effort: Balanced
Standalone native command output on Windows is screen-scraped from the console buffer only after the process exits, so with -IncludeTimeStamp every line of that block receives the completion time of the command. The console buffer does not record per-line write times, so per-line production times cannot be recovered for this path without redirecting the native output, which would change how the command renders to the console. Piped or redirected native output already streams through transcription line by line and gets accurate per-line timestamps. Document this in the Start-Transcript parameter help and at the screen-scrape transcription site, and add a regression test for timestamped native command output (piped, so it does not depend on a physical console being available in the test environment).
Redirecting native command output directly to a file (for example 'native.exe > out.txt') transfers the bytes straight to the file and bypasses transcription entirely, so it must not be suggested as a way to capture per-line output. Only piping the native output into a PowerShell command (for example 'native.exe | Out-Host') streams it through the pipeline, where each line is recorded and timestamped as it is produced. Fix the guidance in the IncludeTimeStamp parameter help, the screen-scrape comment in NativeCommandProcessor, and the PR description accordingly.
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.


PR Summary
Add an opt-in
-IncludeTimeStampswitch toStart-Transcriptthat prefixes each recorded line of command input and output with the time it was produced, so long-running or headless scripts can be reviewed chronologically without cross-referencing external logs.PR Context
Resolves #24135
Design notes:
yyyy-MM-dd HH:mm:ss, invariant culture, local time ?????? consistent with the rest of the transcript, which uses local time) is applied when output is queued to the transcript buffer rather than when it is flushed to disk, so it reflects the time the output was actually produced.PS> .../>> ...) are also prefixed.-IncludeInvocationHeaderbanners are left unchanged since they already embed timestamps.native.exe | Out-Host) streams it through transcription line by line, so each line gets an accurate timestamp; redirecting native output directly to a file (e.g.native.exe > out.txt) bypasses transcription entirely.PR Checklist
Start-Transcript -IncludeTimeStampparameter that prefixes each transcribed output line with ayyyy-MM-dd HH:mm:sstimestamp.).h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep it open).