mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
Adds support to store debugmode state in config and make it globally available
This commit is contained in:
parent
e8f2152010
commit
dff16d8f0d
4 changed files with 27 additions and 9 deletions
|
|
@ -29,15 +29,6 @@ function Use-Icinga()
|
|||
Import-IcingaLib '\' -Init -Custom;
|
||||
Import-IcingaLib '\' -Init;
|
||||
|
||||
$EventLogMessages = Invoke-IcingaNamespaceCmdlets -Command 'Register-IcingaEventLogMessages*';
|
||||
foreach ($entry in $EventLogMessages.Values) {
|
||||
foreach ($event in $entry.Keys) {
|
||||
Add-IcingaHashtableItem -Hashtable $global:IcingaEventLogEnums `
|
||||
-Key $event `
|
||||
-Value $entry[$event] | Out-Null;
|
||||
}
|
||||
}
|
||||
|
||||
if ($LibOnly -eq $FALSE) {
|
||||
Register-IcingaEventLog;
|
||||
|
||||
|
|
@ -66,6 +57,21 @@ function Use-Icinga()
|
|||
$global:IcingaDaemonData.FrameworkRunningAsDaemon = $Daemon;
|
||||
}
|
||||
}
|
||||
|
||||
# Enable DebugMode in case it is enabled in our config
|
||||
if (Get-IcingaFrameworkDebugMode) {
|
||||
Enable-IcingaFrameworkDebugMode;
|
||||
$DebugMode = $TRUE;
|
||||
}
|
||||
|
||||
$EventLogMessages = Invoke-IcingaNamespaceCmdlets -Command 'Register-IcingaEventLogMessages*';
|
||||
foreach ($entry in $EventLogMessages.Values) {
|
||||
foreach ($event in $entry.Keys) {
|
||||
Add-IcingaHashtableItem -Hashtable $global:IcingaEventLogEnums `
|
||||
-Key $event `
|
||||
-Value $entry[$event] | Out-Null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Import-IcingaLib()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
function Disable-IcingaFrameworkDebugMode()
|
||||
{
|
||||
$global:IcingaDaemonData.DebugMode = $FALSE;
|
||||
Set-IcingaPowerShellConfig -Path 'Framework.DebugMode' -Value $FALSE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
function Enable-IcingaFrameworkDebugMode()
|
||||
{
|
||||
$global:IcingaDaemonData.DebugMode = $TRUE;
|
||||
Set-IcingaPowerShellConfig -Path 'Framework.DebugMode' -Value $TRUE;
|
||||
}
|
||||
|
|
|
|||
10
lib/core/framework/Get-IcingaFrameworkDebugMode.psm1
Normal file
10
lib/core/framework/Get-IcingaFrameworkDebugMode.psm1
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
function Get-IcingaFrameworkDebugMode()
|
||||
{
|
||||
$DebugMode = Get-IcingaPowerShellConfig -Path 'Framework.DebugMode';
|
||||
|
||||
if ($null -eq $DebugMode) {
|
||||
return $FALSE;
|
||||
}
|
||||
|
||||
return $DebugMode;
|
||||
}
|
||||
Loading…
Reference in a new issue