diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2020-01-12 15:57:41 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2020-01-12 15:57:41 +0200 |
| commit | eb56ae78a58d07f5e11c2c034a67be96256a4c87 (patch) | |
| tree | 0009bba7a19390453642c9d7b1648bf8f16c62e4 /Software | |
| parent | 9949e351e152a929da696ef2f0a1f8b1668e83fa (diff) | |
| parent | d8b3bbece9ee09b68b6707c276ce4101f91e2943 (diff) | |
| download | Tango-eb56ae78a58d07f5e11c2c034a67be96256a4c87.tar.gz Tango-eb56ae78a58d07f5e11c2c034a67be96256a4c87.zip | |
MERGE
Diffstat (limited to 'Software')
6 files changed, 103 insertions, 4 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/ViewModels/MainViewVM.cs index e9f2404e0..ea6584556 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/ViewModels/MainViewVM.cs @@ -21,7 +21,7 @@ namespace Tango.MachineStudio.ActionLogs.ViewModels { public class MainViewVM : StudioViewModel { - #region properties + #region Properties private DateTime _startSelectedDate; public DateTime StartSelectedDate diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs index b3e121253..bfd5b0557 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs @@ -241,6 +241,20 @@ namespace Tango.MachineStudio.UI.TFS } } + //Add session log file.. + if (MachineOperator.EnableSessionLogFile) + { + var file = MachineOperator.SessionLogger.LogFile; + var sessionLogFile = _tempFolder.CreateImaginaryFile(); + File.Copy(file, sessionLogFile.Path); + item.Attachments.Add(new Attachment() + { + Description = "Session Log File", + FilePath = sessionLogFile.Path, + Name = Path.GetFileName(file), + }); + } + SystemInformationModel sysModel = new SystemInformationModel(); sysModel.ApplicationVersion = app.Version.ToString(); sysModel.EmbeddedVersion = "N/A"; diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BugReporting/TFS/TeamFoundationServicePPCClient.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BugReporting/TFS/TeamFoundationServicePPCClient.cs index c28c5fcba..eb5b8f283 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BugReporting/TFS/TeamFoundationServicePPCClient.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BugReporting/TFS/TeamFoundationServicePPCClient.cs @@ -134,6 +134,20 @@ namespace Tango.PPC.BugReporting.TFS } } + //Add session log file.. + if (MachineOperator.EnableSessionLogFile) + { + var file = MachineOperator.SessionLogger.LogFile; + var sessionLogFile = tempFolder.CreateImaginaryFile(); + File.Copy(file, sessionLogFile.Path); + item.Attachments.Add(new Attachment() + { + Description = "Session Log File", + FilePath = sessionLogFile.Path, + Name = Path.GetFileName(file), + }); + } + SystemInformationModel sysModel = new SystemInformationModel(); sysModel.ApplicationVersion = _applicationManager.Version.ToString(); sysModel.EmbeddedVersion = "N/A"; diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeTcpClient.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeTcpClient.cs index ca019affe..5d20cedf3 100644 --- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeTcpClient.cs +++ b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeTcpClient.cs @@ -107,6 +107,9 @@ namespace Tango.Integration.ExternalBridge LogRequestSent(login); var response = await SendRequest<ExternalBridgeLoginRequest, ExternalBridgeLoginResponse>(login); + + SessionLogger.CreateSession(); + DeviceInformation = response.Message.DeviceInformation; if (!response.Message.Authenticated) { @@ -236,6 +239,9 @@ namespace Tango.Integration.ExternalBridge } State = TransportComponentState.Disconnected; + + SessionLogger.EndSession(); + if (Adapter != null) { await Adapter.Disconnect(); diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index 30f2e9b0a..c84d9cfec 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -77,6 +77,8 @@ namespace Tango.Integration.Operation public static String EmbeddedLogsFolder { get; private set; } public static String EmbeddedLogsTag { get; private set; } + public static SessionFileLogger SessionLogger { get; set; } + #region Constructors /// <summary> @@ -94,6 +96,12 @@ namespace Tango.Integration.Operation FileLogger fileLogger = new FileLogger(EmbeddedLogsFolder, EmbeddedLogsTag) { Enabled = true }; EmbeddedLogManager.RegisterLogger(fileLogger); } + + if (SessionLogger == null) + { + SessionLogger = new SessionFileLogger(); + LogManager.Default.RegisterLogger(SessionLogger); + } } /// <summary> @@ -249,6 +257,18 @@ namespace Tango.Integration.Operation #endregion #region Properties + /// <summary> + /// Gets or sets a value indicating whether to create a new designated session log file each successful connection. + /// This log file will contain standard logs that have occurred between the last connection and disconnection states. + /// </summary> + public static bool EnableSessionLogFile + { + get { return SessionLogger.Enabled; } + set + { + SessionLogger.Enabled = value; + } + } /// <summary> /// Gets or sets the job handling mode. @@ -1160,6 +1180,8 @@ namespace Tango.Integration.Operation Status = MachineStatuses.Disconnected; + SessionLogger.EndSession(); + if (State == TransportComponentState.Connected) { DisconnectRequest request = new DisconnectRequest(); @@ -1212,6 +1234,9 @@ namespace Tango.Integration.Operation try { var response = await SendRequest<ConnectRequest, ConnectResponse>(request); + + SessionLogger.CreateSession(); + LogResponseReceived(response.Message); _isPowerDownRequestInProgress = false; diff --git a/Software/Visual_Studio/Tango.Logging/SessionFileLogger.cs b/Software/Visual_Studio/Tango.Logging/SessionFileLogger.cs index f3c23ca25..f4ce9c2fb 100644 --- a/Software/Visual_Studio/Tango.Logging/SessionFileLogger.cs +++ b/Software/Visual_Studio/Tango.Logging/SessionFileLogger.cs @@ -10,12 +10,22 @@ namespace Tango.Logging { public class SessionFileLogger : ILogger { + #region Properties private bool _inInSession; - public const string FILE_SESSION_EXTENSION = "_session"; + private int _writeCount; + public const string FILE_SESSION_EXTENSION = "_session"; + public static String DefaultLogsFolder { get; private set; } + private const int FILE_SIZE_CHECK_COUNT = 100; + + /// <summary> + /// Gets or sets the maximum file size limit. + /// </summary> + public static long MaxFileSizeLimit { get; set; } + public bool Enabled { get; set; } public String Folder { get; private set; } @@ -24,9 +34,15 @@ namespace Tango.Logging public String Tag { get; private set; } + #endregion + #region Constructors + /// <summary> + /// Initializes the static members of the class. + /// </summary> static SessionFileLogger() { - DefaultLogsFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Twine", "Tango", "Logs", Path.GetFileNameWithoutExtension(AppDomain.CurrentDomain.FriendlyName), "session"); + DefaultLogsFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Twine", "Tango", "Logs", Path.GetFileNameWithoutExtension(AppDomain.CurrentDomain.FriendlyName), "Session"); + MaxFileSizeLimit = 1000000 * 10; //10 MB } public SessionFileLogger(String folder, String tag) @@ -35,13 +51,17 @@ namespace Tango.Logging Tag = tag; Directory.CreateDirectory(Folder); Enabled = true; + _writeCount = 0; } public SessionFileLogger() : this(DefaultLogsFolder, Path.GetFileNameWithoutExtension(AppDomain.CurrentDomain.FriendlyName)) { } - + #endregion + /// <summary> + /// Creates the session. Only one file should be for session log, so removed old file and create a new file. + /// </summary> public void CreateSession() { RemoveOldLogFile(); @@ -49,16 +69,26 @@ namespace Tango.Logging _inInSession = true; } + /// <summary> + /// Ends the session. Set flag _inInSession to false. + /// </summary> public void EndSession() { _inInSession = false; } + /// <summary> + /// Creates the name of the log file. + /// </summary> + /// <returns></returns> private String CreateLogFileName() { return Path.Combine(Folder, string.Format("{1}-{0:dd-MM-yyyy_HH-mm-ss}{2}.log", DateTime.Now, Tag, FILE_SESSION_EXTENSION)); } + /// <summary> + /// Delete the old log file if is existed. + /// </summary> private void RemoveOldLogFile() { try @@ -85,12 +115,22 @@ 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 |
