aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-04-10 15:06:42 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-04-10 15:06:42 +0300
commitb4682a3abfe299c19b24752b2fb1ce2477611ec3 (patch)
tree1d7c87eb5c3eba0d4bf7103fa8717ba62faaccc2 /Software/Visual_Studio/PPC
parentd03741164872fc4d849407ed877b6ea00220cc67 (diff)
downloadTango-b4682a3abfe299c19b24752b2fb1ce2477611ec3.tar.gz
Tango-b4682a3abfe299c19b24752b2fb1ce2477611ec3.zip
Implemented FSE/PPC Logs.
Diffstat (limited to 'Software/Visual_Studio/PPC')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/FileSystem/DefaultFileSystemService.cs46
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Shared/Logs/GetLogFilesRequest.cs13
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Shared/Logs/GetLogFilesResponse.cs18
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Shared/Logs/RemoteLogFile.cs17
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Shared/Logs/RemoteLogFileType.cs14
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Shared/Tango.PPC.Shared.csproj4
6 files changed, 112 insertions, 0 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/FileSystem/DefaultFileSystemService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/FileSystem/DefaultFileSystemService.cs
index 02975a2b3..86506abcf 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/FileSystem/DefaultFileSystemService.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/FileSystem/DefaultFileSystemService.cs
@@ -11,7 +11,10 @@ using Tango.Core.IO;
using Tango.FileSystem;
using Tango.FileSystem.Network;
using Tango.Integration.ExternalBridge;
+using Tango.Integration.Operation;
+using Tango.Logging;
using Tango.PPC.Common.ExternalBridge;
+using Tango.PPC.Shared.Logs;
using Tango.Transport;
using Tango.Transport.Transporters;
using Tango.WebRTC;
@@ -360,6 +363,49 @@ namespace Tango.PPC.Common.FileSystem
await receiver.SendGenericResponse(new PerformDiskSpaceOptimizationResponse() { DeletedBytes = deletedBytes }, token);
}
+ [ExternalBridgeRequestHandlerMethod(typeof(GetLogFilesRequest), RequestHandlerLoggingMode.LogRequestNameAndContent)]
+ public async Task OnGetLogFilesRequest(GetLogFilesRequest request, String token, ExternalBridgeReceiver receiver)
+ {
+ FolderItem folder = null;
+
+ if (request.LogFileType == RemoteLogFileType.Application)
+ {
+ var fileLogger = LogManager.RegisteredLoggers.SingleOrDefault(x => x.GetType() == typeof(FileLogger)) as FileLogger;
+
+ if (fileLogger == null)
+ {
+ throw new InvalidOperationException("Could not locate the application file logger.");
+ }
+
+ folder = await _manager.GetFolder(fileLogger.Folder, false, "*.log") as FolderItem;
+ }
+ else
+ {
+ if (MachineOperator.EmbeddedLogsFolder == null)
+ {
+ throw new InvalidOperationException("The firmware file logger folder could not be read.");
+ }
+
+ folder = await _manager.GetFolder(MachineOperator.EmbeddedLogsFolder, false, "*.log") as FolderItem;
+ }
+
+ GetLogFilesResponse response = new GetLogFilesResponse();
+
+ foreach (var file in folder.Items.OfType<FileItem>().OrderByDescending(x => x.DateCreated).DistinctBy(x => x.Name))
+ {
+ response.LogFiles.Add(new RemoteLogFile()
+ {
+ DateModified = file.DateModified,
+ DateCreated = file.DateCreated,
+ Name = file.Name,
+ Path = file.Path,
+ Length = new FileInfo(file.Path).Length
+ });
+ }
+
+ await receiver.SendGenericResponse(response, token);
+ }
+
public void OnReceiverDisconnected(ExternalBridgeReceiver receiver)
{
if (_webRtcClients.ContainsKey(receiver))
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Logs/GetLogFilesRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Logs/GetLogFilesRequest.cs
new file mode 100644
index 000000000..bb5d21837
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Logs/GetLogFilesRequest.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.PPC.Shared.Logs
+{
+ public class GetLogFilesRequest
+ {
+ public RemoteLogFileType LogFileType { get; set; }
+ }
+}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Logs/GetLogFilesResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Logs/GetLogFilesResponse.cs
new file mode 100644
index 000000000..cf5d59726
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Logs/GetLogFilesResponse.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.PPC.Shared.Logs
+{
+ public class GetLogFilesResponse
+ {
+ public List<RemoteLogFile> LogFiles { get; set; }
+
+ public GetLogFilesResponse()
+ {
+ LogFiles = new List<RemoteLogFile>();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Logs/RemoteLogFile.cs b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Logs/RemoteLogFile.cs
new file mode 100644
index 000000000..fc2ba88c4
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Logs/RemoteLogFile.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.PPC.Shared.Logs
+{
+ public class RemoteLogFile
+ {
+ public String Name { get; set; }
+ public DateTime DateModified { get; set; }
+ public DateTime DateCreated { get; set; }
+ public String Path { get; set; }
+ public long Length { get; set; }
+ }
+}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Logs/RemoteLogFileType.cs b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Logs/RemoteLogFileType.cs
new file mode 100644
index 000000000..958b4c195
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Logs/RemoteLogFileType.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.PPC.Shared.Logs
+{
+ public enum RemoteLogFileType
+ {
+ Application,
+ Firmware
+ }
+}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Tango.PPC.Shared.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Tango.PPC.Shared.csproj
index 2ae1c7575..96c18129a 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Tango.PPC.Shared.csproj
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Tango.PPC.Shared.csproj
@@ -60,6 +60,10 @@
<Compile Include="Information\GetMachineInformationRequest.cs" />
<Compile Include="Information\GetMachineInformationResponse.cs" />
<Compile Include="Information\InformationPackage.cs" />
+ <Compile Include="Logs\GetLogFilesRequest.cs" />
+ <Compile Include="Logs\GetLogFilesResponse.cs" />
+ <Compile Include="Logs\RemoteLogFile.cs" />
+ <Compile Include="Logs\RemoteLogFileType.cs" />
<Compile Include="Performance\PerformancePackage.cs" />
<Compile Include="Performance\StartPerformanceUpdatesRequest.cs" />
<Compile Include="Performance\StartPerformanceUpdatesResponse.cs" />