mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 11:51:26 -07:00
Ansible.Basic - event log perm fix and no_log improv (#54699)
* Ansible.Basic - event log perm fix and no_log improv * Still log other failures
This commit is contained in:
parent
064d89a850
commit
b13fa0d408
2 changed files with 24 additions and 15 deletions
|
@ -315,7 +315,16 @@ namespace Ansible.Basic
|
|||
using (EventLog eventLog = new EventLog("Application"))
|
||||
{
|
||||
eventLog.Source = logSource;
|
||||
eventLog.WriteEntry(message, logEntryType, 0);
|
||||
try
|
||||
{
|
||||
eventLog.WriteEntry(message, logEntryType, 0);
|
||||
}
|
||||
catch (System.InvalidOperationException) { } // Ignore permission errors on the Application event log
|
||||
catch (System.Exception e)
|
||||
{
|
||||
// Cannot call Warn as that calls LogEvent and we get stuck in a loop
|
||||
warnings.Add(String.Format("Unknown error when creating event log entry: {0}", e.Message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1249,7 +1258,7 @@ namespace Ansible.Basic
|
|||
return "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER";
|
||||
foreach (string omitMe in noLogStrings)
|
||||
if (stringValue.Contains(omitMe))
|
||||
return (stringValue).Replace(omitMe, new String('*', omitMe.Length));
|
||||
return (stringValue).Replace(omitMe, "********");
|
||||
value = stringValue;
|
||||
}
|
||||
return value;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue