Structured PowerShell logging with dual console/file output, rich text formatting, animated progress indicators, and debug-level function tracing.
- Dual output - simultaneous console (colored) and file logging with buffered writes
- Rich formatting - tables, centered blocks, inline headers, timelines, lists, and separators
- Animated progress - background runspace execution with spinner/dots/braille/bounce/box indicators
- Size-based rotation - automatic log file archival with timestamp when size limit is exceeded
- Debug tracing - function entry/exit logging with full parameter capture
- Cross-platform - PowerShell 5.1 (Desktop) and PowerShell 7+ (Core)
Install-Module -Name MEMZone.WriteLog -Scope CurrentUserClone the repository and import the module directly:
git clone https://github.com/MEM-Zone/MEM.Zone-WriteLog.git
Import-Module ./MEM.Zone-WriteLog/src/MEMZone.WriteLog/MEMZone.WriteLog.psd1Import-Module MEMZone.WriteLog
# Initialize logging
Initialize-WriteLog -LogName 'MyScript' -LogPath 'C:\Logs\MyScript'
# Write messages with different formatting
Write-Log -Message 'Operation completed successfully'
Write-Log -Message 'DEPLOYMENT' -FormatOptions @{ Mode = 'InlineHeader'; ForegroundColor = 'Cyan' }
Write-Log -Severity 'Warning' -Message 'Disk space is running low'
# Display a formatted table
$Data = @(
[PSCustomObject]@{ Server = 'SRV01'; Status = 'Online'; CPU = '23%' }
[PSCustomObject]@{ Server = 'SRV02'; Status = 'Offline'; CPU = 'N/A' }
)
Write-Log -Message $Data -FormatOptions @{
Mode = 'Table'
Title = 'Server Status'
CellPadding = 1
AddEmptyRow = 'BeforeAndAfter'
}
# Execute with animated progress
Invoke-WithAnimation -Message 'Copying files' -ScriptBlock {
Copy-Item -Path $Source -Destination $Dest -Recurse
}
# Execute in current session with status indicator
Invoke-WithStatus -Message 'Loading module' -ScriptBlock {
Import-Module SomeModule
}
# Flush remaining log buffer
Write-LogBuffer| Function | Description |
|---|---|
Initialize-WriteLog |
Configure logging (path, console output, debug, rotation size) |
Write-Log |
Write a structured log entry with severity and formatting |
Write-LogBuffer |
Flush the in-memory buffer to the log file |
Test-LogFile |
Ensure log directory/file exist; rotate if oversized |
Format-Message |
Format text as Block, Table, Timeline, List, Header, etc. |
Write-FunctionHeaderOrFooter |
Debug-trace function entry/exit with parameters |
Invoke-WithAnimation |
Run a scriptblock with animated console progress |
Invoke-WithStatus |
Run a scriptblock with synchronous status indicator |
Format-Message and Write-Log -FormatOptions support these modes:
| Mode | Output |
|---|---|
Block |
Full-width separator box with arrow prefix |
CenteredBlock |
Full-width separator box with centered text |
Line |
Single separator line |
InlineHeader |
===[ TITLE ]=== |
InlineSubHeader |
---[ title ]--- |
Timeline |
- message (indented bullet) |
TimelineHeader |
message (indented, no bullet) |
List |
Key-value pairs from hashtable/PSCustomObject |
Table |
Formatted table with headers, row numbers, optional footer |
# Run static analysis and tests
./build/build.ps1
# Run specific tasks
./build/build.ps1 -Task Analyze
./build/build.ps1 -Task Test
./build/build.ps1 -Task Build
# Full pipeline: analyze, test, build, publish
./build/build.ps1 -Task Analyze, Test, Build, Publish -NuGetApiKey $env:NUGET_API_KEY- Pester 5.0+
- PSScriptAnalyzer
The repository includes GitHub Actions workflows:
- CI (
ci.yml) - runs on every push/PR tomain: PSScriptAnalyzer + Pester on Windows and Ubuntu. - Publish (
publish.yml) - runs on version tags (v*): full pipeline + publish to PSGallery.
To publish, create a tag:
git tag v1.0.0
git push origin v1.0.0The NUGET_API_KEY secret must be configured in the repository settings.
- Fork the repository
- Create a feature branch (
git checkout -b feature/my-feature) - Add tests for any new functionality
- Ensure
./build/build.ps1passes - Submit a pull request
This project is licensed under the MIT License.