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:
Jordan Borean 2019-04-03 06:49:43 +10:00 committed by GitHub
parent 064d89a850
commit b13fa0d408
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 15 deletions

View file

@ -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;