Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[common.vm] Improve VM-Write-Log #1249

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading