From 9b947dc0698928757a9570d8b5ff5ca1e0a00912 Mon Sep 17 00:00:00 2001 From: Christian Stein Date: Tue, 24 Mar 2020 20:07:34 +0100 Subject: [PATCH] Adds additional eventlog write functions --- lib/core/logging/Write-IcingaDebugMessage.psm1 | 4 ++++ lib/core/logging/Write-IcingaErrorMessage.psm1 | 13 +++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 lib/core/logging/Write-IcingaErrorMessage.psm1 diff --git a/lib/core/logging/Write-IcingaDebugMessage.psm1 b/lib/core/logging/Write-IcingaDebugMessage.psm1 index 473d129..4ba204f 100644 --- a/lib/core/logging/Write-IcingaDebugMessage.psm1 +++ b/lib/core/logging/Write-IcingaDebugMessage.psm1 @@ -4,6 +4,10 @@ function Write-IcingaDebugMessage() [string]$Message ); + if ([string]::IsNullOrEmpty($Message)) { + return; + } + if ($global:IcingaDaemonData.DebugMode -eq $FALSE) { return; } diff --git a/lib/core/logging/Write-IcingaErrorMessage.psm1 b/lib/core/logging/Write-IcingaErrorMessage.psm1 new file mode 100644 index 0000000..a90190f --- /dev/null +++ b/lib/core/logging/Write-IcingaErrorMessage.psm1 @@ -0,0 +1,13 @@ +function Write-IcingaErrorMessage() +{ + param( + [int]$EventId = 0, + [string]$Message = $null + ); + + if ($EventId -eq 0 -Or [string]::IsNullOrEmpty($Message)) { + return; + } + + Write-EventLog -LogName Application -Source 'Icinga for Windows' -EntryType Error -EventId $EventId -Message $Message; +}