improve formatting of "show threads"

0.7.2-post-fixes
Justin Clark-Casey (justincc) 2011-11-15 22:51:12 +00:00
parent f7b5d17aa2
commit 1bc0d0fac6
1 changed files with 8 additions and 1 deletions

View File

@ -243,6 +243,9 @@ namespace OpenSim.Framework.Servers
/// </summary> /// </summary>
protected string GetThreadsReport() protected string GetThreadsReport()
{ {
// This should be a constant field.
string reportFormat = "{0,6} {1,35} {2,16} {3,10} {4,30}";
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
Watchdog.ThreadWatchdogInfo[] threads = Watchdog.GetThreads(); Watchdog.ThreadWatchdogInfo[] threads = Watchdog.GetThreads();
@ -250,12 +253,16 @@ namespace OpenSim.Framework.Servers
int timeNow = Util.EnvironmentTickCount(); int timeNow = Util.EnvironmentTickCount();
sb.AppendFormat(reportFormat, "ID", "NAME", "LAST UPDATE (MS)", "PRIORITY", "STATE");
sb.Append(Environment.NewLine);
foreach (Watchdog.ThreadWatchdogInfo twi in threads) foreach (Watchdog.ThreadWatchdogInfo twi in threads)
{ {
Thread t = twi.Thread; Thread t = twi.Thread;
sb.AppendFormat( sb.AppendFormat(
"ID: {0}, Name: {1}, Last Update: {2} ms ago, Pri: {3}, State: {4}", reportFormat,
//t.ManagedThreadId, t.Name, string.Format("{0} ms", timeNow - twi.LastTick), t.Priority, t.ThreadState);
t.ManagedThreadId, t.Name, timeNow - twi.LastTick, t.Priority, t.ThreadState); t.ManagedThreadId, t.Name, timeNow - twi.LastTick, t.Priority, t.ThreadState);
sb.Append(Environment.NewLine); sb.Append(Environment.NewLine);