Skip to content

Commit

Permalink
Fix duration log formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
tmolenh committed Sep 26, 2020
1 parent e1d9a86 commit e627e43
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions Get-NetView.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -94,23 +94,21 @@ $ExecFunctions = {
)

$status, [Int] $duration, $commandOut = TestCommand -Command $Command
$duration = ("{0,6:n0}" -f $duration)

# Mirror command execution context
Write-Output "$env:USERNAME @ ${env:COMPUTERNAME}:"

# Mirror command to execute
Write-Output "$(prompt)$Command"

if ($status -eq [CommandStatus]::Success) {
$logMsg = "($duration ms) $Command"
} else {
$logMsg = "($duration ms) [$status] $Command"
$logPrefix = "({0,6:n0} ms)" -f $duration
if ($status -ne [CommandStatus]::Success) {
$logPrefix = "$logPrefix [$status]"
Write-Output "[$status]"
}
Write-Output $commandOut

Write-CmdLog "$logMsg"
Write-CmdLog "$logPrefix $Command"

if ($Global:DelayFactor -gt 0) {
Start-Sleep -Milliseconds ($duration * $Global:DelayFactor + 0.50) # round up
Expand Down

0 comments on commit e627e43

Please sign in to comment.