Code cleanup

This commit is contained in:
Stone_Red
2026-06-10 00:29:28 +02:00
parent 91e8cbb00a
commit 31e54c1637
11 changed files with 184 additions and 186 deletions
-3
View File
@@ -1,8 +1,5 @@
using Cosmos.Kernel.System.Graphics;
using Org.BouncyCastle.Bcpg;
using RemSox.Processes;
using RemSox.Processing;
using RemSox.UI.GUI.Windows;
namespace RemSox.UI.CLI.Commands;
+27 -32
View File
@@ -1,44 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using RemSox.Logging;
using RemSox.Processing;
namespace RemSox.UI.CLI.Commands
namespace RemSox.UI.CLI.Commands;
public class ViewProcessLogs : ICommand
{
public class ViewProcessLogs : ICommand
public string Name => "logs";
public string Description => "View logs for a process";
public void Execute(string? arguments, Action<string> printLine)
{
public string Name => "logs";
public string Description => "View logs for a process";
public void Execute(string? arguments, Action<string> printLine)
if (int.TryParse(arguments, out int processId))
{
if (int.TryParse(arguments, out int processId))
{
IEnumerable<LogEntry> logs = ProcessManager.GetProcessLogs(processId);
PrintLogs(logs, printLine);
}
else
{
IEnumerable<LogEntry> logs = ProcessManager.GetLogs();
PrintLogs(logs, printLine);
}
IEnumerable<LogEntry> logs = ProcessManager.GetProcessLogs(processId);
PrintLogs(logs, printLine);
}
else
{
IEnumerable<LogEntry> logs = ProcessManager.GetLogs();
PrintLogs(logs, printLine);
}
}
private static void PrintLogs(IEnumerable<LogEntry> logs, Action<string> printLine)
{
if (!logs.Any())
{
printLine("No logs found!");
return;
}
private static void PrintLogs(IEnumerable<LogEntry> logs, Action<string> printLine)
foreach (LogEntry log in logs)
{
if (!logs.Any())
{
printLine("No logs found!");
return;
}
foreach (LogEntry log in logs)
{
printLine($"[{log.Timestamp:HH:mm:ss}] [{log.Severity}] {log.Message}");
}
printLine($"[{log.Timestamp:HH:mm:ss}] [{log.Severity}] {log.Message}");
}
}
}