Skip to content

Commit

Permalink
Fix logging to include error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
jvlflame committed Sep 3, 2020
1 parent 92f27b0 commit a0fc491
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Javinizer/Private/Write-JVLog.ps1
Expand Up @@ -51,6 +51,16 @@ function Write-JVLog {
if ($Level -eq 'Error') {
if ($writeLevel -eq 'Debug' -or $WriteLevel -eq 'Info' -or $WriteLevel -eq 'Warning' -or $WriteLevel -eq 'Error') {
$formattedMessage = "[$timeStamp][ERROR] $Message"
if ($LogPath -ne '' -and $null -ne $LogPath) {
if ($formattedMessage -ne '' -and $null -ne $formattedMessage) {
if ($Write -eq 1) {
$LogMutex = New-Object System.Threading.Mutex($false, "LogMutex")
$LogMutex.WaitOne() | Out-Null
$formattedMessage | Out-File -FilePath $LogPath -Append
$LogMutex.ReleaseMutex() | Out-Null
}
}
}
}
Write-Error -Message $Message -ErrorAction $Action
}
Expand Down

0 comments on commit a0fc491

Please sign in to comment.