mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 07:10:15 -05:00
Adds improved handling for error messages and later doc on website
This commit is contained in:
parent
9831e9319c
commit
a78ac014be
2 changed files with 38 additions and 0 deletions
14
lib/core/logging/Icinga_EventLog_Enums.psm1
Normal file
14
lib/core/logging/Icinga_EventLog_Enums.psm1
Normal 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' );
|
||||||
24
lib/core/logging/Write-IcingaEventMessage.psm1
Normal file
24
lib/core/logging/Write-IcingaEventMessage.psm1
Normal 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;
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue