Adds unified debug message output with object parsing ability

This commit is contained in:
Christian Stein 2020-03-27 16:37:44 +01:00
parent 699137a97c
commit e8f2152010
2 changed files with 12 additions and 3 deletions

View file

@ -7,7 +7,12 @@
#> #>
[hashtable]$IcingaEventLogEnums += @{ [hashtable]$IcingaEventLogEnums += @{
'Framework' = @{ '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;
};
} }
}; };

View file

@ -1,7 +1,8 @@
function Write-IcingaDebugMessage() function Write-IcingaDebugMessage()
{ {
param( param(
[string]$Message [string]$Message,
[array]$Objects = @()
); );
if ([string]::IsNullOrEmpty($Message)) { if ([string]::IsNullOrEmpty($Message)) {
@ -12,5 +13,8 @@ function Write-IcingaDebugMessage()
return; 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;
} }