Adds improved handling for error messages and later doc on website

This commit is contained in:
Christian Stein 2020-03-25 08:35:29 +01:00
parent 9831e9319c
commit a78ac014be
2 changed files with 38 additions and 0 deletions

View file

@ -0,0 +1,14 @@
<#
# This script will provide 'Enums' we can use for proper
# error handling and to provide more detailed descriptions
#
# Example usage:
# $IcingaEventLogEnums[2000]
#>
[hashtable]$IcingaEventLogEnums += @{
'Framework' = @{
# TODO: Add event log messages
}
};
Export-ModuleMember -Variable @( 'IcingaEventLogEnums' );

View file

@ -0,0 +1,24 @@
function Write-IcingaEventMessage()
{
param(
[int]$EventId = 0,
[string]$Namespace = $null
);
if ($EventId -eq 0 -Or $null -eq $Namespace) {
return;
}
$EntryType = $IcingaEventLogEnums[$Namespace][$EventId].EntryType;
$Message = $IcingaEventLogEnums[$Namespace][$EventId].Message;
if ($null -eq $EntryType -Or $null -eq $Message) {
return;
}
Write-EventLog -LogName Application `
-Source 'Icinga for Windows' `
-EntryType $EntryType `
-EventId $EventId `
-Message $Message;
}