Add LogTools
This commit is contained in:
30
HelperFunctions/LogTools.ps1
Normal file
30
HelperFunctions/LogTools.ps1
Normal file
@@ -0,0 +1,30 @@
|
||||
Function Add-LogEntry {
|
||||
Param (
|
||||
[Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()]$Message,
|
||||
[Parameter(Mandatory = $false)] [ValidateSet('Notify', 'Warning', 'Error')]$As,
|
||||
[Parameter(Mandatory = $false)] [Switch]$NewLine
|
||||
)
|
||||
$Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
|
||||
|
||||
Switch ($As) {
|
||||
"Notify" {
|
||||
$FGC = "Cyan"
|
||||
}
|
||||
"Warning" {
|
||||
$FGC = "Yellow"
|
||||
}
|
||||
"Error" {
|
||||
$FGC = "Red"
|
||||
}
|
||||
Default {
|
||||
$FGC = "White"
|
||||
}
|
||||
}
|
||||
|
||||
If ($Newline) {
|
||||
Write-Host "`n[$Timestamp] $Message" -ForegroundColor $FGC
|
||||
}
|
||||
Else {
|
||||
Write-Host "[$Timestamp] $Message" -ForegroundColor $FGC
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user