From 5d534127663899cd5592c865b1d00855fce25854 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Sun, 29 Jun 2014 16:40:11 +0300 Subject: Write UDP statistics to the log, not just the console (e.g., "show queues") --- OpenSim/Framework/Monitoring/StatsManager.cs | 53 ++++++++++++---------------- 1 file changed, 22 insertions(+), 31 deletions(-) (limited to 'OpenSim/Framework/Monitoring/StatsManager.cs') diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs index 0bac247..5c8d934 100644 --- a/OpenSim/Framework/Monitoring/StatsManager.cs +++ b/OpenSim/Framework/Monitoring/StatsManager.cs @@ -30,6 +30,8 @@ using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; +using System.Reflection; +using log4net; using OpenSim.Framework; using OpenMetaverse.StructuredData; @@ -41,6 +43,8 @@ namespace OpenSim.Framework.Monitoring /// public static class StatsManager { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + // Subcommand used to list other stats. public const string AllSubCommand = "all"; @@ -98,6 +102,7 @@ namespace OpenSim.Framework.Monitoring public static void HandleShowStatsCommand(string module, string[] cmd) { ICommandConsole con = MainConsole.Instance; + StringBuilder report = new StringBuilder(); if (cmd.Length > 2) { @@ -111,7 +116,8 @@ namespace OpenSim.Framework.Monitoring if (categoryName == AllSubCommand) { - OutputAllStatsToConsole(con); + foreach (string report2 in GetAllStatsReports()) + report.AppendLine(report2); } else if (categoryName == ListSubCommand) { @@ -130,7 +136,8 @@ namespace OpenSim.Framework.Monitoring { if (String.IsNullOrEmpty(containerName)) { - OutputCategoryStatsToConsole(con, category); + foreach (string report2 in GetCategoryStatsReports(category)) + report.AppendLine(report2); } else { @@ -139,14 +146,15 @@ namespace OpenSim.Framework.Monitoring { if (String.IsNullOrEmpty(statName)) { - OutputContainerStatsToConsole(con, container); + foreach (string report2 in GetContainerStatsReports(container)) + report.AppendLine(report2); } else { Stat stat; if (container.TryGetValue(statName, out stat)) { - OutputStatToConsole(con, stat); + report.AppendLine(stat.ToConsoleString()); } else { @@ -168,10 +176,18 @@ namespace OpenSim.Framework.Monitoring { // Legacy if (SimExtraStats != null) - con.Output(SimExtraStats.Report()); + { + report.Append(SimExtraStats.Report()); + } else - OutputAllStatsToConsole(con); + { + foreach (string report2 in GetAllStatsReports()) + report.AppendLine(report2); + } } + + if (report.Length > 0) + m_log.Debug(string.Join(" ", cmd) + "\n" + report.ToString()); } public static List GetAllStatsReports() @@ -184,12 +200,6 @@ namespace OpenSim.Framework.Monitoring return reports; } - private static void OutputAllStatsToConsole(ICommandConsole con) - { - foreach (string report in GetAllStatsReports()) - con.Output(report); - } - private static List GetCategoryStatsReports( SortedDictionary> category) { @@ -201,13 +211,6 @@ namespace OpenSim.Framework.Monitoring return reports; } - private static void OutputCategoryStatsToConsole( - ICommandConsole con, SortedDictionary> category) - { - foreach (string report in GetCategoryStatsReports(category)) - con.Output(report); - } - private static List GetContainerStatsReports(SortedDictionary container) { List reports = new List(); @@ -218,18 +221,6 @@ namespace OpenSim.Framework.Monitoring return reports; } - private static void OutputContainerStatsToConsole( - ICommandConsole con, SortedDictionary container) - { - foreach (string report in GetContainerStatsReports(container)) - con.Output(report); - } - - private static void OutputStatToConsole(ICommandConsole con, Stat stat) - { - con.Output(stat.ToConsoleString()); - } - // Creates an OSDMap of the format: // { categoryName: { // containerName: { -- cgit v1.1