Skip to content

Commit 34d8df9

Browse files
committed
Fix Join-Path syntax in Logging-Core module
1 parent 6ce5e60 commit 34d8df9

2 files changed

Lines changed: 95 additions & 1 deletion

File tree

Modules/Logging-Core.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ $script:LogLevels = @{
3434
'ERROR' = 3
3535
'CRITICAL' = 4
3636
}
37-
$script:DefaultLogPath = Join-Path $env:ProgramData "WindowsServerSolutions" "Logs"
37+
$script:DefaultLogPath = Join-Path -Path $env:ProgramData -ChildPath "WindowsServerSolutions" | Join-Path -ChildPath "Logs"
3838
$script:LogTargets = @{
3939
File = $true
4040
Console = $true

Modules/TEST-Modules.ps1

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<#
2+
.SYNOPSIS
3+
Test script for enhanced error handling and logging modules
4+
5+
.DESCRIPTION
6+
Validates that both modules load and function correctly.
7+
8+
.NOTES
9+
Author: Adrian Johnson (adrian207@gmail.com)
10+
Version: 1.0.0
11+
#>
12+
13+
[CmdletBinding()]
14+
param()
15+
16+
Write-Host "=== Testing Enhanced Error Handling and Logging Modules ===" -ForegroundColor Cyan
17+
Write-Host ""
18+
19+
# Test 1: Import Modules
20+
Write-Host "Test 1: Importing modules..." -ForegroundColor Yellow
21+
try {
22+
$loggingPath = Resolve-Path "Modules\Logging-Core.psm1"
23+
$errorHandlingPath = Resolve-Path "Modules\Error-Handling.psm1"
24+
25+
Import-Module $loggingPath -Force -ErrorAction Stop
26+
Import-Module $errorHandlingPath -Force -ErrorAction Stop
27+
28+
Write-Host "✅ Both modules imported successfully" -ForegroundColor Green
29+
Write-Host ""
30+
} catch {
31+
Write-Host "❌ Module import failed: $_" -ForegroundColor Red
32+
exit 1
33+
}
34+
35+
# Test 2: Check Module Versions
36+
Write-Host "Test 2: Checking module versions..." -ForegroundColor Yellow
37+
$modules = Get-Module -Name "Logging-Core", "Error-Handling"
38+
foreach ($module in $modules) {
39+
Write-Host " $($module.Name): v$($module.Version)" -ForegroundColor Gray
40+
}
41+
42+
Write-Host "✅ Module versions retrieved" -ForegroundColor Green
43+
Write-Host ""
44+
45+
# Test 3: Test Logging
46+
Write-Host "Test 3: Testing logging functionality..." -ForegroundColor Yellow
47+
try {
48+
Write-Log -Message "Test INFO message" -Level INFO -Component "TestModule"
49+
Write-Log -Message "Test WARNING message" -Level WARNING -Component "TestModule"
50+
Write-Log -Message "Test ERROR message" -Level ERROR -Component "TestModule"
51+
Write-Host "✅ Logging test passed" -ForegroundColor Green
52+
} catch {
53+
Write-Host "❌ Logging test failed: $_" -ForegroundColor Red
54+
exit 1
55+
}
56+
Write-Host ""
57+
58+
# Test 4: Test Error Handling
59+
Write-Host "Test 4: Testing error handling..." -ForegroundColor Yellow
60+
try {
61+
Invoke-CommandWithRetry -ScriptBlock {
62+
Get-Service -Name "Themes" -ErrorAction Stop
63+
} -MaxRetries 2 -OperationName "TestRetry"
64+
Write-Host "✅ Error handling test passed" -ForegroundColor Green
65+
} catch {
66+
Write-Host "❌ Error handling test failed: $_" -ForegroundColor Red
67+
exit 1
68+
}
69+
Write-Host ""
70+
71+
# Test 5: Test Get-ErrorDetails
72+
Write-Host "Test 5: Testing error details..." -ForegroundColor Yellow
73+
try {
74+
try {
75+
Get-Process -Name "NonExistentProcess12345" -ErrorAction Stop
76+
} catch {
77+
$details = Get-ErrorDetails -ErrorObject $_
78+
Write-Host " Error type: $($details.Type)" -ForegroundColor Gray
79+
Write-Host " Error message: $($details.Message)" -ForegroundColor Gray
80+
}
81+
Write-Host "✅ Error details test passed" -ForegroundColor Green
82+
} catch {
83+
Write-Host "❌ Error details test failed: $_" -ForegroundColor Red
84+
}
85+
Write-Host ""
86+
87+
Write-Host "=== All Tests Passed ===" -ForegroundColor Green
88+
Write-Host ""
89+
Write-Host "Module Status:" -ForegroundColor Cyan
90+
Write-Host " Logging-Core: Working ✅" -ForegroundColor Green
91+
Write-Host " Error-Handling: Working ✅" -ForegroundColor Green
92+
Write-Host ""
93+
Write-Host "Version: 1.0.0" -ForegroundColor Gray
94+

0 commit comments

Comments
 (0)