diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-08-30 09:05:59 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-08-30 09:05:59 +0300 |
| commit | dceb1f65f3c648238690cfde848385c8fae6baae (patch) | |
| tree | ee606d7f050504a98177934862cb818926b33a17 /Software/Visual_Studio/Tango.Logging | |
| parent | 883a5aa210d213b89b463b113c551a3f8924970f (diff) | |
| download | Tango-dceb1f65f3c648238690cfde848385c8fae6baae.tar.gz Tango-dceb1f65f3c648238690cfde848385c8fae6baae.zip | |
Added JsonIgnore to some props in LogItemBase.
Dropped SkipFileLoggin from Tango.Logging.
Diffstat (limited to 'Software/Visual_Studio/Tango.Logging')
6 files changed, 23 insertions, 27 deletions
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 /// <param name="output">The output.</param> 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 /// <summary> /// Gets or sets an optional log object. /// </summary> + [JsonIgnore] public Object LogObject { @@ -29,17 +31,6 @@ namespace Tango.Logging set { _logObject = value; } } - [NonSerialized] - private bool _skipFileLogging; - /// <summary> - /// Gets or sets a value indicating whether this log should not be written to a file. - /// </summary> - public bool SkipFileLogging - { - get { return _skipFileLogging; } - set { _skipFileLogging = value; } - } - /// <summary> /// Gets or sets the caller method adding the exception. /// </summary> @@ -53,6 +44,7 @@ namespace Tango.Logging /// <summary> /// Gets the relative caller file. /// </summary> + [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 /// </summary> /// <param name="e">Exception.</param> /// <param name="description">Error description.</param> - 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); } /// <summary> @@ -112,7 +112,7 @@ namespace Tango.Logging /// </summary> /// <param name="e">Exception.</param> /// <param name="description">Error description.</param> - 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. /// </summary> /// <param name="message">Message.</param> - 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); } /// <summary> /// Add new message log item. /// </summary> /// <param name="message">Message.</param> - 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); } /// <summary> /// Add new message log item. /// </summary> /// <param name="message">Message.</param> - 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 /// <param name="output">The output.</param> 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 @@ <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> + <Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> + <HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath> + </Reference> <Reference Include="PresentationCore" /> <Reference Include="PresentationFramework" /> <Reference Include="System" /> @@ -80,10 +83,13 @@ <Generator>MSBuild:Compile</Generator> </Page> </ItemGroup> + <ItemGroup> + <None Include="packages.config" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> + <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> </VisualStudio> </ProjectExtensions> </Project>
\ 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="Newtonsoft.Json" version="9.0.1" targetFramework="net461" /> +</packages>
\ No newline at end of file |
