Skip to content

Commit

Permalink
Merged PR 1755: 3794 Investigate Proper log colors for Unicorn sync
Browse files Browse the repository at this point in the history
Color-coded logging does not work because of issue in Cake (example: cake-build/cake#1633) and there is no obvious fix for it, so I've enabled "Warning/Info/Error" prefixes and removed Info/Debug entries from PS console output by default (visible when Sync.ps1 is called directly)

How it looks now on initial deploy:

![image.png](https://dev.azure.com/sitecoredst/f9b5d027-f29c-449f-826c-d7bb655b30f4/_apis/git/repositories/7a4bd0ee-c068-422b-8891-a5085900757d/pullRequests/1755/attachments/image.png)

Related work items: #3794
  • Loading branch information
Alexander Doroshenko authored and scottmulligan committed Nov 27, 2019
2 parents 057315d + 838cbe3 commit 7b698ad
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions scripts/Unicorn/Unicorn.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,26 @@ Function Invoke-StreamingWebRequest($Uri, $MAC, $Nonce) {
$responseStreamReader = new-object System.IO.StreamReader $responseStream

while(-not $responseStreamReader.EndOfStream) {
$line = $responseStreamReader.ReadLine()
$line = $responseStreamReader.ReadLine().Trim()
if([string]::IsNullOrEmpty($line))
{
continue
}

if($line.StartsWith('Error:')) {
Write-Host $line.Substring(7) -ForegroundColor Red
Write-Host $line -ForegroundColor Red
}
elseif($line.StartsWith('Warning:')) {
Write-Host $line.Substring(9) -ForegroundColor Yellow
}
elseif($line.StartsWith('Debug:')) {
Write-Host $line.Substring(7) -ForegroundColor Gray
Write-Host $line -ForegroundColor Yellow
}
elseif($line.StartsWith('Info:')) {
Write-Host $line.Substring(6) -ForegroundColor White
Write-Verbose $line -Verbose
}
elseif($line.StartsWith('Debug:')) {
Write-Verbose $line -Verbose
}
else {
Write-Host $line -ForegroundColor White
Write-Host $line
}

[void]$responseText.AppendLine($line)
Expand Down

0 comments on commit 7b698ad

Please sign in to comment.