2022-01-14 16:18:59 -05:00
function Publish-IcingaEventLogDocumentation ( )
2021-08-06 12:12:27 -04:00
{
param (
[ string ] $Namespace ,
[ string ] $OutFile
) ;
[ string ] $DocContent = [ string ] :: Format (
2022-01-14 16:18:59 -05:00
'# {0} EventLog Documentation' ,
2021-08-06 12:12:27 -04:00
$Namespace
) ;
$DocContent + = New-IcingaNewLine ;
$DocContent + = New-IcingaNewLine ;
2022-01-14 16:18:59 -05:00
$DocContent + = " Below you will find a list of EventId's which are exported by this module. The short and detailed message are both written directly into the EventLog. This documentation shall simply provide a summary of available EventId's " ;
2021-08-06 12:12:27 -04:00
$SortedArray = $IcingaEventLogEnums [ $Namespace ] . Keys . GetEnumerator ( ) | Sort-Object ;
foreach ( $entry in $SortedArray ) {
$entry = $IcingaEventLogEnums [ $Namespace ] [ $entry ] ;
$DocContent = [ string ] :: Format (
'{0}{2}{2}## Event Id {1}{2}{2}| Category | Short Message | Detailed Message |{2}| --- | --- | --- |{2}| {3} | {4} | {5} |' ,
$DocContent ,
$entry . EventId ,
( New-IcingaNewLine ) ,
$entry . EntryType ,
$entry . Message ,
$entry . Details
) ;
}
if ( [ string ] :: IsNullOrEmpty ( $OutFile ) ) {
Write-Output $DocContent ;
} else {
Write-IcingaFileSecure -File $OutFile -Value $DocContent ;
}
}