Skip to content
Snippets Groups Projects
Commit 308e5151 authored by Niko Ehrenfeuchter's avatar Niko Ehrenfeuchter :keyboard:
Browse files

Generalize process names logging to SystemChecks.LogRunningProcesses()

Relates to #64, #52
parent 6200dcc8
Branches update_count_reads
No related tags found
No related merge requests found
......@@ -115,5 +115,39 @@ namespace ATxCommon
return username == "";
}
/// <summary>
/// Log names of running processes if loglevel is set to debug.
/// </summary>
/// <param name="longFormat">By default only the process names will be printed to the
/// log, enclosed by square brackets (e.g. [explorer]). If "longFormat" is set to true,
/// each process name will be printed on a separate line, followed by the title of the
/// corresponding main window (if existing).</param>
public static void LogRunningProcesses(bool longFormat=false) {
if (!Log.IsDebugEnabled)
return;
if (longFormat)
Log.Debug("\n\n>>>>>>>>>>>> running processes >>>>>>>>>>>>");
var procs = "";
foreach (var running in Process.GetProcesses()) {
if (longFormat) {
var title = running.MainWindowTitle;
if (title.Length > 0) {
title = " (\"" + title + "\")";
}
Log.Debug(" - {0}{1}", running.ProcessName, title);
} else {
procs += $", [{running.ProcessName}]";
}
}
if (longFormat) {
Log.Debug("\n<<<<<<<<<<<< running processes <<<<<<<<<<<<\n");
} else {
Log.Debug("Currently running processes: {0}", procs.Substring(2));
}
}
}
}
......@@ -41,15 +41,7 @@ namespace ATxDiagnostics
Log.Debug("Free space on drive [C:]: " + Conv.BytesToString(SystemChecks.GetFreeDriveSpace("C:")));
Log.Debug("\n\n>>>>>>>>>>>> running processes >>>>>>>>>>>>");
foreach (var running in Process.GetProcesses()) {
var title = running.MainWindowTitle;
if (title.Length > 0) {
title = " (\"" + title + "\")";
}
Log.Debug(" - {0}{1}", running.ProcessName, title);
}
Log.Debug("\n<<<<<<<<<<<< running processes <<<<<<<<<<<<\n");
SystemChecks.LogRunningProcesses(true);
if (perfMonitors.Contains("CPU")) {
Log.Info("Watching CPU load using ATxCommon.Monitoring...");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment