aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Logging/SessionFileLogger.cs
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2020-01-12 16:03:38 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2020-01-12 16:03:38 +0200
commit5502a2d3f6ec945809da9b16b7dccdd3716a820e (patch)
tree5f511259f973e981d534db7b4118a78b08276e21 /Software/Visual_Studio/Tango.Logging/SessionFileLogger.cs
parenteb56ae78a58d07f5e11c2c034a67be96256a4c87 (diff)
downloadTango-5502a2d3f6ec945809da9b16b7dccdd3716a820e.tar.gz
Tango-5502a2d3f6ec945809da9b16b7dccdd3716a820e.zip
Code comments for session logger.
Diffstat (limited to 'Software/Visual_Studio/Tango.Logging/SessionFileLogger.cs')
-rw-r--r--Software/Visual_Studio/Tango.Logging/SessionFileLogger.cs74
1 files changed, 43 insertions, 31 deletions
diff --git a/Software/Visual_Studio/Tango.Logging/SessionFileLogger.cs b/Software/Visual_Studio/Tango.Logging/SessionFileLogger.cs
index f4ce9c2fb..da8079d41 100644
--- a/Software/Visual_Studio/Tango.Logging/SessionFileLogger.cs
+++ b/Software/Visual_Studio/Tango.Logging/SessionFileLogger.cs
@@ -10,22 +10,24 @@ namespace Tango.Logging
{
public class SessionFileLogger : ILogger
{
- #region Properties
private bool _inInSession;
-
private int _writeCount;
+ private const string FILE_SESSION_EXTENSION = "_session";
+ private const int FILE_SIZE_CHECK_COUNT = 100;
- public const string FILE_SESSION_EXTENSION = "_session";
-
- public static String DefaultLogsFolder { get; private set; }
+ #region Static Properties
- private const int FILE_SIZE_CHECK_COUNT = 100;
+ public static String DefaultLogsFolder { get; private set; }
/// <summary>
/// Gets or sets the maximum file size limit.
/// </summary>
public static long MaxFileSizeLimit { get; set; }
+ #endregion
+
+ #region Properties
+
public bool Enabled { get; set; }
public String Folder { get; private set; }
@@ -35,6 +37,7 @@ namespace Tango.Logging
public String Tag { get; private set; }
#endregion
+
#region Constructors
/// <summary>
/// Initializes the static members of the class.
@@ -59,6 +62,9 @@ namespace Tango.Logging
}
#endregion
+
+ #region Public Methods
+
/// <summary>
/// Creates the session. Only one file should be for session log, so removed old file and create a new file.
/// </summary>
@@ -78,6 +84,35 @@ namespace Tango.Logging
}
/// <summary>
+ /// Called when write to session log file.
+ /// </summary>
+ /// <param name="output">The output.</param>
+ public void OnLog(LogItemBase output)
+ {
+ if (_inInSession)
+ {
+ try
+ {
+ if (++_writeCount > FILE_SIZE_CHECK_COUNT && new FileInfo(LogFile).Length > MaxFileSizeLimit)
+ {
+ _writeCount = 0;
+ CreateSession();
+ File.AppendAllText(LogFile, "### This log file is a continuation of a previous log file ###" + Environment.NewLine + Environment.NewLine);
+ }
+ File.AppendAllText(LogFile, output.ToString() + Environment.NewLine);
+ }
+ catch
+ {
+ Debug.WriteLine("Error Writing To Session Log File!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+ }
+ }
+ }
+
+ #endregion
+
+ #region Private Methods
+
+ /// <summary>
/// Creates the name of the log file.
/// </summary>
/// <returns></returns>
@@ -113,31 +148,8 @@ namespace Tango.Logging
{
Debug.WriteLine(ex);
}
- }
+ }
- /// <summary>
- /// Called when write to session log file.
- /// </summary>
- /// <param name="output">The output.</param>
- public void OnLog(LogItemBase output)
- {
- if (_inInSession)
- {
- try
- {
- if(++_writeCount > FILE_SIZE_CHECK_COUNT && new FileInfo(LogFile).Length > MaxFileSizeLimit)
- {
- _writeCount = 0;
- CreateSession();
- File.AppendAllText(LogFile, "### This log file is a continuation of a previous log file ###" + Environment.NewLine + Environment.NewLine);
- }
- File.AppendAllText(LogFile, output.ToString() + Environment.NewLine);
- }
- catch
- {
- Debug.WriteLine("Error Writing To Session Log File!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
- }
- }
- }
+ #endregion
}
}