feat: Logging when we intentionally restart the program or processor

This commit is contained in:
Chris Cameron
2021-05-17 15:30:53 -04:00
parent 28335ad99c
commit 1390af967f
2 changed files with 18 additions and 0 deletions

View File

@@ -213,6 +213,10 @@ namespace ICD.Common.Utils
[PublicAPI] [PublicAPI]
public static void RestartProgram() public static void RestartProgram()
{ {
ILoggerService logger = ServiceProvider.TryGetService<ILoggerService>();
if (logger != null)
logger.AddEntry(eSeverity.Informational, "Intentional Restart of Program");
string consoleResult = string.Empty; string consoleResult = string.Empty;
string command = string.Format("progreset -p:{0:D2}", ProgramUtils.ProgramNumber); string command = string.Format("progreset -p:{0:D2}", ProgramUtils.ProgramNumber);
IcdConsole.SendControlSystemCommand(command, ref consoleResult); IcdConsole.SendControlSystemCommand(command, ref consoleResult);
@@ -224,6 +228,10 @@ namespace ICD.Common.Utils
[PublicAPI] [PublicAPI]
public static void Reboot() public static void Reboot()
{ {
ILoggerService logger = ServiceProvider.TryGetService<ILoggerService>();
if (logger != null)
logger.AddEntry(eSeverity.Informational, "Intentional Reboot of Processor");
string consoleResult = string.Empty; string consoleResult = string.Empty;
IcdConsole.SendControlSystemCommand("reboot", ref consoleResult); IcdConsole.SendControlSystemCommand("reboot", ref consoleResult);
} }

View File

@@ -5,6 +5,8 @@ using System.Linq;
using System.Management; using System.Management;
using ICD.Common.Properties; using ICD.Common.Properties;
using ICD.Common.Utils.IO; using ICD.Common.Utils.IO;
using ICD.Common.Utils.Services;
using ICD.Common.Utils.Services.Logging;
using Microsoft.Win32; using Microsoft.Win32;
namespace ICD.Common.Utils namespace ICD.Common.Utils
@@ -163,6 +165,10 @@ namespace ICD.Common.Utils
if (string.IsNullOrEmpty(filename) || !IcdFile.Exists(filename)) if (string.IsNullOrEmpty(filename) || !IcdFile.Exists(filename))
throw new InvalidOperationException("Failed to find program filename"); throw new InvalidOperationException("Failed to find program filename");
ILoggerService logger = ServiceProvider.TryGetService<ILoggerService>();
if (logger != null)
logger.AddEntry(eSeverity.Informational, "Intentional Restart of Program");
Process.Start(filename); Process.Start(filename);
Environment.Exit(0); Environment.Exit(0);
} }
@@ -173,6 +179,10 @@ namespace ICD.Common.Utils
[PublicAPI] [PublicAPI]
public static void Reboot() public static void Reboot()
{ {
ILoggerService logger = ServiceProvider.TryGetService<ILoggerService>();
if (logger != null)
logger.AddEntry(eSeverity.Informational, "Intentional Reboot of Processor");
// TODO - Linux // TODO - Linux
ProcessStartInfo psi = ProcessStartInfo psi =
new ProcessStartInfo("shutdown", "/r /t 0") new ProcessStartInfo("shutdown", "/r /t 0")