Skip to content

Commit

Permalink
Merge pull request #1249 from Ana06/VM-Write-Log
Browse files Browse the repository at this point in the history
[common.vm] Improve VM-Write-Log
  • Loading branch information
sara-rn authored Jan 22, 2025
2 parents a34d650 + 079f02e commit 6bf6463
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/common.vm/common.vm.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>common.vm</id>
<version>0.0.0.20241216</version>
<version>0.0.0.20250116</version>
<description>Common libraries for VM-packages</description>
<authors>Mandiant</authors>
</metadata>
Expand Down
15 changes: 11 additions & 4 deletions packages/common.vm/tools/vm.common/vm.common.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,18 @@ function VM-Remove-PreviousZipPackage {
}
}


function VM-Write-Log {
<#
.SYNOPSIS
Log message to file and console.
.DESCRIPTION
Log message to log file with extra useful information and to console with a color depending on the level.
#>
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true, Position=0)]
[ValidateSet("INFO","WARN","ERROR","FATAL","DEBUG")]
[ValidateSet("INFO","WARN","ERROR")]
[String] $level,
[Parameter(Mandatory=$true, Position=1)]
[string] $message
Expand Down Expand Up @@ -106,11 +113,11 @@ function VM-Write-Log {

# Log message to console
if (($level -eq "ERROR") -Or ($level -eq "FATAL")) {
Write-Host -ForegroundColor Red -BackgroundColor White "$line"
Write-Host -ForegroundColor Red -BackgroundColor White "$message"
} elseif ($level -eq "WARN") {
Write-Host -ForegroundColor Yellow "$line"
Write-Host -ForegroundColor Yellow "$message"
} else {
Write-Host "$line"
Write-Host -ForegroundColor Cyan "$message"
}
}

Expand Down

0 comments on commit 6bf6463

Please sign in to comment.