Skip to content

Commit ee5442e

Browse files
committed
Add support the optional delphi-logger functionality.
Inject Write-CDHostLog snippet (v0.1.0) with BEGIN-CD-HOSTLOG / END-CD-HOSTLOG seam markers for automated refresh from delphi-logger. Migrate all Write-Output, Write-Information, Write-Verbose, Write-Warning, and Write-Error calls to Write-CDHostLog. Custom output helpers (Write-Detail, Write-Summary, Write-Section, Write-SummarySection) now route through Write-CDHostLog internally and use -LogOnly when display is suppressed by -OutputLevel or -Json, so the logger captures events even when console output is quiet. Add Complete-CDActivity at all exit points. Guard outer catch against null exception messages. Add tools/delphi-logger/ debug scripts for version, clean (WhatIf), check, and showconfig commands. Add tools/update-delphilogger.bat for snippet refresh. For issue #30
1 parent 4ac69e8 commit ee5442e

13 files changed

Lines changed: 248 additions & 57 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# PowerShell test output
22
tests/pwsh/results/*.xml
3+
tools/delphi-logger/**/debug.log

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All notable changes to this project will be documented in this file.
44

55
---
6+
## [1.1.0] - 2026-05-14
7+
8+
- Support for `delphi-logger` added (opt-in structural logging for debug
9+
purposes.) [#30](https://github.com/continuous-delphi/delphi-clean/issues/30)
610

711
## [1.0.0] 2026-05-13
812

source/delphi-clean.ps1

Lines changed: 165 additions & 57 deletions
Large diffs are not rendered by default.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Shared log dump helper for delphi-clean debug scripts.
2+
# Dot-source this at the end of each debug.ps1 to write captured
3+
# events to debug.log in the caller's folder.
4+
5+
$callerDir = Split-Path -Parent $MyInvocation.PSCommandPath
6+
$debugLogFile = Join-Path $callerDir 'debug.log'
7+
$eventCount = (Get-CDLogEvents).Count
8+
9+
Get-CDLogEvents | ForEach-Object {
10+
'{0} [{1}] {2}' -f $_.timestampUtc, $_.level.ToUpperInvariant(), $_.message
11+
} | Set-Content -Path $debugLogFile -Encoding utf8
12+
13+
Write-Host "Log written: $eventCount events to $debugLogFile"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@echo off
2+
pushd "%~dp0"
3+
pwsh -NoProfile -File "%~dp0debug.ps1"
4+
pause
5+
popd
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Import-Module ContinuousDelphi.Logger
2+
Initialize-CDLogger -Source 'delphi-clean' -OutputMode Silent -MinimumLevel Trace -CaptureOutput $true
3+
4+
& "$PSScriptRoot\..\..\..\source\delphi-clean.ps1" `
5+
-Level deep `
6+
-RootPath 'C:\code\delphi-lexer' `
7+
-OutputLevel detailed `
8+
-Check
9+
10+
. "$PSScriptRoot\..\Write-CDDebugLog.ps1"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@echo off
2+
pushd "%~dp0"
3+
pwsh -NoProfile -File "%~dp0debug.ps1"
4+
pause
5+
popd
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Import-Module ContinuousDelphi.Logger
2+
Initialize-CDLogger -Source 'delphi-clean' -OutputMode Silent -MinimumLevel Trace -CaptureOutput $true
3+
4+
& "$PSScriptRoot\..\..\..\source\delphi-clean.ps1" `
5+
-Level deep `
6+
-RootPath 'C:\code\delphi-lexer' `
7+
-OutputLevel detailed `
8+
-WhatIf
9+
10+
. "$PSScriptRoot\..\Write-CDDebugLog.ps1"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@echo off
2+
pushd "%~dp0"
3+
pwsh -NoProfile -File "%~dp0debug.ps1"
4+
pause
5+
popd
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Import-Module ContinuousDelphi.Logger
2+
Initialize-CDLogger -Source 'delphi-clean' -OutputMode Silent -MinimumLevel Trace -CaptureOutput $true
3+
4+
& "$PSScriptRoot\..\..\..\source\delphi-clean.ps1" `
5+
-Level deep `
6+
-RootPath 'C:\code\delphi-lexer' `
7+
-ShowConfig
8+
9+
. "$PSScriptRoot\..\Write-CDDebugLog.ps1"

0 commit comments

Comments
 (0)