aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Logging/FileLogger.cs
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-09-05 13:30:41 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-09-05 13:30:41 +0300
commit341262cb539e0c3e26ed54080675034276bc7b4a (patch)
tree31d5da06cd91769cc87bbae4362830f4aaf6cd37 /Software/Visual_Studio/Tango.Logging/FileLogger.cs
parentc7043303d96ec48af6af105a93d80dca2aed627b (diff)
downloadTango-341262cb539e0c3e26ed54080675034276bc7b4a.tar.gz
Tango-341262cb539e0c3e26ed54080675034276bc7b4a.zip
Fixed mid tanks levels demo naming convention.
Added unique machine password to disk cache db. Added password protection features to FileLogger.
Diffstat (limited to 'Software/Visual_Studio/Tango.Logging/FileLogger.cs')
-rw-r--r--Software/Visual_Studio/Tango.Logging/FileLogger.cs23
1 files changed, 21 insertions, 2 deletions
diff --git a/Software/Visual_Studio/Tango.Logging/FileLogger.cs b/Software/Visual_Studio/Tango.Logging/FileLogger.cs
index 0839a5ee7..3c3ae970d 100644
--- a/Software/Visual_Studio/Tango.Logging/FileLogger.cs
+++ b/Software/Visual_Studio/Tango.Logging/FileLogger.cs
@@ -4,6 +4,7 @@ using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
+using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Threading;
@@ -22,6 +23,12 @@ namespace Tango.Logging
private int _fileExtensionIndex;
private const int FILE_SIZE_CHECK_COUNT = 100;
public const string FILE_SET_EXTENSION = "__";
+ private Regex _passwordRegEx;
+
+ /// <summary>
+ /// Gets or sets a value indicating whether to automatically locate password inside log messages and hide them.
+ /// </summary>
+ public bool ProtectPasswords { get; set; }
/// <summary>
/// Gets the logs folder.
@@ -81,7 +88,6 @@ namespace Tango.Logging
/// </summary>
public long MaxFileSizeLimit { get; set; }
-
public String GetFileSetExtension(int index)
{
return FILE_SET_EXTENSION + index;
@@ -122,6 +128,8 @@ namespace Tango.Logging
EnableMaxFileSizeLimit = true;
MaxFileSizeLimit = 1000000 * 10;
_fileExtensionIndex = 0;
+
+ _passwordRegEx = new Regex("(\"(|.+)password\":)(|\\s)(\"[^,\"]+\")", RegexOptions.IgnoreCase);
}
/// <summary>
@@ -164,7 +172,18 @@ namespace Tango.Logging
}
}
- File.AppendAllText(LogFile, output.ToString() + Environment.NewLine);
+ String logString = output.ToString();
+
+ if (ProtectPasswords)
+ {
+ try
+ {
+ logString = _passwordRegEx.Replace(logString, x => $"{x.Groups[1].Value}{x.Groups[3].Value}\"{new String('*', x.Groups[4].Length)}\"");
+ }
+ catch { }
+ }
+
+ File.AppendAllText(LogFile, logString + Environment.NewLine);
}
catch
{