From dceb1f65f3c648238690cfde848385c8fae6baae Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sun, 30 Aug 2020 09:05:59 +0300 Subject: Added JsonIgnore to some props in LogItemBase. Dropped SkipFileLoggin from Tango.Logging. --- Software/Visual_Studio/Tango.Logging/FileLogger.cs | 2 -- Software/Visual_Studio/Tango.Logging/LogItemBase.cs | 16 ++++------------ Software/Visual_Studio/Tango.Logging/LogManager.cs | 18 ++++++++---------- .../Visual_Studio/Tango.Logging/SessionFileLogger.cs | 2 -- .../Visual_Studio/Tango.Logging/Tango.Logging.csproj | 8 +++++++- Software/Visual_Studio/Tango.Logging/packages.config | 4 ++++ 6 files changed, 23 insertions(+), 27 deletions(-) create mode 100644 Software/Visual_Studio/Tango.Logging/packages.config (limited to 'Software/Visual_Studio/Tango.Logging') diff --git a/Software/Visual_Studio/Tango.Logging/FileLogger.cs b/Software/Visual_Studio/Tango.Logging/FileLogger.cs index 041b56be4..0839a5ee7 100644 --- a/Software/Visual_Studio/Tango.Logging/FileLogger.cs +++ b/Software/Visual_Studio/Tango.Logging/FileLogger.cs @@ -138,8 +138,6 @@ namespace Tango.Logging /// The output. public void OnLog(LogItemBase output) { - if (output.SkipFileLogging) return; - try { if (DateTime.Now.Date > _logFileTimeDate.Date) diff --git a/Software/Visual_Studio/Tango.Logging/LogItemBase.cs b/Software/Visual_Studio/Tango.Logging/LogItemBase.cs index 944f61130..d5271d213 100644 --- a/Software/Visual_Studio/Tango.Logging/LogItemBase.cs +++ b/Software/Visual_Studio/Tango.Logging/LogItemBase.cs @@ -1,4 +1,5 @@ -using System; +using Newtonsoft.Json; +using System; using System.Collections.Generic; using System.ComponentModel; using System.IO; @@ -22,6 +23,7 @@ namespace Tango.Logging /// /// Gets or sets an optional log object. /// + [JsonIgnore] public Object LogObject { @@ -29,17 +31,6 @@ namespace Tango.Logging set { _logObject = value; } } - [NonSerialized] - private bool _skipFileLogging; - /// - /// Gets or sets a value indicating whether this log should not be written to a file. - /// - public bool SkipFileLogging - { - get { return _skipFileLogging; } - set { _skipFileLogging = value; } - } - /// /// Gets or sets the caller method adding the exception. /// @@ -53,6 +44,7 @@ namespace Tango.Logging /// /// Gets the relative caller file. /// + [JsonIgnore] public String RelativeCallerFile { get { return GetRelativeCallerFilePath(); } diff --git a/Software/Visual_Studio/Tango.Logging/LogManager.cs b/Software/Visual_Studio/Tango.Logging/LogManager.cs index 4148fa342..ba73b32b4 100644 --- a/Software/Visual_Studio/Tango.Logging/LogManager.cs +++ b/Software/Visual_Studio/Tango.Logging/LogManager.cs @@ -102,9 +102,9 @@ namespace Tango.Logging /// /// Exception. /// Error description. - public Exception Log(Exception e, String description = null, bool skipFileLogging = false, [CallerMemberName] string caller = null, [CallerFilePath] string file = null, [CallerLineNumber] int lineNumber = 0) + public Exception Log(Exception e, String description = null, [CallerMemberName] string caller = null, [CallerFilePath] string file = null, [CallerLineNumber] int lineNumber = 0) { - return Log(e, LogCategory.Error, description, skipFileLogging, caller, file, lineNumber); + return Log(e, LogCategory.Error, description, caller, file, lineNumber); } /// @@ -112,7 +112,7 @@ namespace Tango.Logging /// /// Exception. /// Error description. - public Exception Log(Exception e, LogCategory category, String description = null, bool skipFileLogging = false, [CallerMemberName] string caller = null, [CallerFilePath] string file = null, [CallerLineNumber] int lineNumber = 0) + public Exception Log(Exception e, LogCategory category, String description = null, [CallerMemberName] string caller = null, [CallerFilePath] string file = null, [CallerLineNumber] int lineNumber = 0) { if (!Categories.Contains(category)) return e; @@ -125,7 +125,6 @@ namespace Tango.Logging log.Category = category; log.Description = description; log.Message = log.Description + Environment.NewLine + log.Exception.FlattenException(); - log.SkipFileLogging = skipFileLogging; AppendLog(log); @@ -136,25 +135,25 @@ namespace Tango.Logging /// Add new message log item. /// /// Message. - public String Log(String message, bool skipFileLogging = false, [CallerMemberName] string caller = null, [CallerFilePath] string file = null, [CallerLineNumber] int lineNumber = 0) + public String Log(String message, [CallerMemberName] string caller = null, [CallerFilePath] string file = null, [CallerLineNumber] int lineNumber = 0) { - return Log(message, LogCategory.Info, null, skipFileLogging, caller, file, lineNumber); + return Log(message, LogCategory.Info, null, caller, file, lineNumber); } /// /// Add new message log item. /// /// Message. - public String Log(String message, LogCategory category, bool skipFileLogging = false, [CallerMemberName] string caller = null, [CallerFilePath] string file = null, [CallerLineNumber] int lineNumber = 0) + public String Log(String message, LogCategory category, [CallerMemberName] string caller = null, [CallerFilePath] string file = null, [CallerLineNumber] int lineNumber = 0) { - return Log(message, category, null, skipFileLogging, caller, file, lineNumber); + return Log(message, category, null, caller, file, lineNumber); } /// /// Add new message log item. /// /// Message. - public String Log(String message, LogCategory category, Object logObject, bool skipFileLogging = false, [CallerMemberName] string caller = null, [CallerFilePath] string file = null, [CallerLineNumber] int lineNumber = 0) + public String Log(String message, LogCategory category, Object logObject, [CallerMemberName] string caller = null, [CallerFilePath] string file = null, [CallerLineNumber] int lineNumber = 0) { if (!Categories.Contains(category)) return message; @@ -166,7 +165,6 @@ namespace Tango.Logging log.Category = category; log.Message = message; log.LogObject = logObject; - log.SkipFileLogging = skipFileLogging; AppendLog(log); diff --git a/Software/Visual_Studio/Tango.Logging/SessionFileLogger.cs b/Software/Visual_Studio/Tango.Logging/SessionFileLogger.cs index efe74c899..4e378bfbf 100644 --- a/Software/Visual_Studio/Tango.Logging/SessionFileLogger.cs +++ b/Software/Visual_Studio/Tango.Logging/SessionFileLogger.cs @@ -102,8 +102,6 @@ namespace Tango.Logging /// The output. public void OnLog(LogItemBase output) { - if (output.SkipFileLogging) return; - if (_inInSession) { try diff --git a/Software/Visual_Studio/Tango.Logging/Tango.Logging.csproj b/Software/Visual_Studio/Tango.Logging/Tango.Logging.csproj index d9a2e1139..549113657 100644 --- a/Software/Visual_Studio/Tango.Logging/Tango.Logging.csproj +++ b/Software/Visual_Studio/Tango.Logging/Tango.Logging.csproj @@ -31,6 +31,9 @@ 4 + + ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll + @@ -80,10 +83,13 @@ MSBuild:Compile + + + - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Logging/packages.config b/Software/Visual_Studio/Tango.Logging/packages.config new file mode 100644 index 000000000..7ee8c1052 --- /dev/null +++ b/Software/Visual_Studio/Tango.Logging/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file -- cgit v1.3.1