From e8f2152010e5f8900e9dd950b101f17240d08097 Mon Sep 17 00:00:00 2001 From: Christian Stein Date: Fri, 27 Mar 2020 16:37:44 +0100 Subject: [PATCH] Adds unified debug message output with object parsing ability --- lib/core/logging/Icinga_EventLog_Enums.psm1 | 7 ++++++- lib/core/logging/Write-IcingaDebugMessage.psm1 | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/core/logging/Icinga_EventLog_Enums.psm1 b/lib/core/logging/Icinga_EventLog_Enums.psm1 index 30cd05b..2b9c9e5 100644 --- a/lib/core/logging/Icinga_EventLog_Enums.psm1 +++ b/lib/core/logging/Icinga_EventLog_Enums.psm1 @@ -7,7 +7,12 @@ #> [hashtable]$IcingaEventLogEnums += @{ 'Framework' = @{ - # TODO: Add event log messages + 1000 = @{ + 'EntryType' = 'Information'; + 'Message' = 'Generic debug message issued by the Framework or its components'; + 'Details' = 'The Framework or is components can issue generic debug message in case the debug log is enabled. Please ensure to disable it, if not used. You can do so with the command "Disable-IcingaFrameworkDebugMode"'; + 'EventId' = 1000; + }; } }; diff --git a/lib/core/logging/Write-IcingaDebugMessage.psm1 b/lib/core/logging/Write-IcingaDebugMessage.psm1 index 187765c..419e290 100644 --- a/lib/core/logging/Write-IcingaDebugMessage.psm1 +++ b/lib/core/logging/Write-IcingaDebugMessage.psm1 @@ -1,7 +1,8 @@ function Write-IcingaDebugMessage() { param( - [string]$Message + [string]$Message, + [array]$Objects = @() ); if ([string]::IsNullOrEmpty($Message)) { @@ -12,5 +13,8 @@ function Write-IcingaDebugMessage() return; } - Write-EventLog -LogName Application -Source 'Icinga for Windows' -EntryType Information -EventId 1000 -Message $Message; + [array]$DebugContent = @($Message); + $DebugContent += $Objects; + + Write-IcingaEventMessage -EventId 1000 -Namespace 'Framework' -Objects $DebugContent; }