123456789101112131415161718192021222324 |
- Get-Content -Path .\logs\rajesh.log -Wait | ForEach-Object {
- if ($_ -match '^\[(.*?)\] <(.*?)> \[(.*?)\] (.*)') {
- $timestamp = $matches[1]
- $fileInfo = $matches[2]
- $level = $matches[3]
- $message = $matches[4]
- switch ($level) {
- 'INFO' { $color = 'Cyan' }
- 'DBUG' { $color = 'Gray' }
- 'WARN' { $color = 'Yellow' }
- 'EROR' { $color = 'Red' }
- 'FTAL' { $color = 'Magenta' }
- default { $color = 'White' }
- }
- Write-Host "[$timestamp]" -ForegroundColor DarkGray -NoNewline
- Write-Host " <$fileInfo>" -ForegroundColor DarkCyan -NoNewline
- Write-Host " [$level]" -ForegroundColor $color -NoNewline
- Write-Host " $message" -ForegroundColor White
- } else {
- Write-Host $_ -ForegroundColor White
- }
- }
|