mirror of
https://github.com/Stone-Red-Code/RemSox.git
synced 2026-09-04 00:56:19 +02:00
Reorganize project structure
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
using RemSox.Kernel.Logging;
|
||||
using RemSox.Kernel.Processing;
|
||||
|
||||
namespace RemSox.Kernel.UI.CLI.Commands;
|
||||
|
||||
public class ViewProcessLogs : ICommand
|
||||
{
|
||||
public string Name => "logs";
|
||||
|
||||
public string Description => "View logs for a process";
|
||||
|
||||
public Task ExecuteAsync(string? arguments, Action<string> printLine)
|
||||
{
|
||||
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);
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private static void PrintLogs(IEnumerable<LogEntry> logs, Action<string> printLine)
|
||||
{
|
||||
if (!logs.Any())
|
||||
{
|
||||
printLine("No logs found!");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (LogEntry log in logs)
|
||||
{
|
||||
printLine($"[{log.Timestamp:HH:mm:ss}] [{log.Severity}] {log.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user