/// <summary> /// Console output is only possible if a console has been established. /// That is something that cannot be determined within this class. So /// all attempts to use the console MUST be verified. /// </summary> /// <param name="msg"></param> protected void Notice(string msg) { if (m_console != null) { m_console.Output(msg); } }
private void HandleShowServerThrottlesCommand(string module, string[] args) { if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene) { return; } m_console.OutputFormat("Throttles for {0}", m_udpServer.Scene.Name); ConsoleDisplayList cdl = new ConsoleDisplayList(); cdl.AddRow("Adaptive throttles", m_udpServer.ThrottleRates.AdaptiveThrottlesEnabled); long maxSceneDripRate = (long)m_udpServer.Throttle.MaxDripRate; cdl.AddRow( "Max scene throttle", maxSceneDripRate != 0 ? string.Format("{0} kbps", maxSceneDripRate * 8 / 1000) : "unset"); int maxClientDripRate = m_udpServer.ThrottleRates.Total; cdl.AddRow( "Max new client throttle", maxClientDripRate != 0 ? string.Format("{0} kbps", maxClientDripRate * 8 / 1000) : "unset"); m_console.Output(cdl.ToString()); m_console.OutputFormat("{0}\n", GetServerThrottlesReport(m_udpServer)); }
public static void HandleShowchecksCommand(string module, string[] cmd) { ICommandConsole con = MainConsole.Instance; if (cmd.Length > 2) { foreach (string name in cmd.Skip(2)) { string[] components = name.Split('.'); string categoryName = components[0]; // string containerName = components.Length > 1 ? components[1] : null; if (categoryName == ListSubCommand) { con.Output("check categories available are:"); foreach (string category in RegisteredChecks.Keys) { con.Output(" {0}", category); } } // else // { // SortedDictionary<string, SortedDictionary<string, Check>> category; // if (!Registeredchecks.TryGetValue(categoryName, out category)) // { // con.OutputFormat("No such category as {0}", categoryName); // } // else // { // if (String.IsNullOrEmpty(containerName)) // { // OutputConfiguredToConsole(con, category); // } // else // { // SortedDictionary<string, Check> container; // if (category.TryGetValue(containerName, out container)) // { // OutputContainerChecksToConsole(con, container); // } // else // { // con.OutputFormat("No such container {0} in category {1}", containerName, categoryName); // } // } // } // } } } else { OutputAllChecksToConsole(con); } }
private static void OutputContainerChecksToConsole(ICommandConsole con, SortedDictionary <string, Check> container) { foreach (Check check in container.Values) { con.Output(check.ToConsoleString()); } }
private static void OutputAllStatsToConsole(ICommandConsole con) { foreach (string report in GetAllStatsReports()) { con.Output(report); } }
private static void OutputCategoryStatsToConsole( ICommandConsole con, SortedDictionary <string, SortedDictionary <string, Stat> > category) { foreach (string report in GetCategoryStatsReports(category)) { con.Output(report); } }
private static void OutputContainerStatsToConsole( ICommandConsole con, SortedDictionary <string, Stat> container) { foreach (string report in GetContainerStatsReports(container)) { con.Output(report); } }
/// <summary> /// Check if the given file path exists. /// </summary> /// <remarks>If not, warning is printed to the given console.</remarks> /// <returns>true if the file does not exist, false otherwise.</returns> /// <param name='console'></param> /// <param name='path'></param> public static bool CheckFileDoesNotExist(ICommandConsole console, string path) { if (File.Exists(path)) { console.Output("File {0} already exists. Please move or remove it.", path); return(false); } return(true); }
public static void HandleShowStatsCommand(string module, string[] cmd) { ICommandConsole con = MainConsole.Instance; if (cmd.Length > 2) { var categoryName = cmd[2]; if (categoryName == AllSubCommand) { foreach (var category in RegisteredStats.Values) { OutputCategoryStatsToConsole(con, category); } } else if (categoryName == ListSubCommand) { con.Output("Statistic categories available are:"); foreach (string category in RegisteredStats.Keys) { con.OutputFormat(" {0}", category); } } else { Dictionary <string, Dictionary <string, Stat> > category; if (!RegisteredStats.TryGetValue(categoryName, out category)) { con.OutputFormat("No such category as {0}", categoryName); } else { OutputCategoryStatsToConsole(con, category); } } } else { // Legacy con.Output(SimExtraStats.Report()); } }
private static void OutputCategoryStatsToConsole( ICommandConsole con, Dictionary <string, Dictionary <string, Stat> > category) { foreach (var container in category.Values) { foreach (Stat stat in container.Values) { con.Output(stat.ToConsoleString()); } } }
public static void HandleStatsRecordCommand(string module, string[] cmd) { ICommandConsole con = MainConsole.Instance; if (cmd.Length != 4) { con.Output("Usage: debug stats record start|stop"); return; } if (cmd[3] == "start") { Start(); con.OutputFormat("Now recording all stats to file every {0}ms", m_statsLogIntervalMs); } else if (cmd[3] == "stop") { Stop(); con.Output("Stopped recording stats to file."); } }
/// <summary> /// Try to parse a console UUID from the console. /// </summary> /// <remarks> /// Will complain to the console if parsing fails. /// </remarks> /// <returns></returns> /// <param name='console'>If null then no complaint is printed.</param> /// <param name='rawUuid'></param> /// <param name='uuid'></param> public static bool TryParseConsoleUuid(ICommandConsole console, string rawUuid, out UUID uuid) { if (!UUID.TryParse(rawUuid, out uuid)) { if (console != null) { console.Output("ERROR: {0} is not a valid uuid", rawUuid); } return(false); } return(true); }
/// <summary> /// Convert a console input to a double, automatically complaining if a console is given. /// </summary> /// <param name='console'>Can be null if no console is available.</param> /// <param name='rawConsoleInput'>/param> /// <param name='i'></param> /// <returns></returns> public static bool TryParseConsoleDouble(ICommandConsole console, string rawConsoleInput, out double i) { if (!double.TryParse(rawConsoleInput, out i)) { if (console != null) { console.Output("ERROR: {0} is not a valid double", rawConsoleInput); } return(false); } return(true); }
/// <summary> /// Convert a console input to a float, automatically complaining if a console is given. /// </summary> /// <param name='console'>Can be null if no console is available.</param> /// <param name='rawConsoleInput'>/param> /// <param name='i'></param> /// <returns></returns> public static bool TryParseConsoleFloat(ICommandConsole console, string rawConsoleInput, out float i) { if (!float.TryParse(rawConsoleInput, out i)) { if (console != null) { console.Output("ERROR: {0} is not a valid float", rawConsoleInput); } return(false); } return(true); }
/// <summary> /// Convert a console input to an int, automatically complaining if a console is given. /// </summary> /// <param name='console'>Can be null if no console is available.</param> /// <param name='rawConsoleInt'>/param> /// <param name='i'></param> /// <returns></returns> public static bool TryParseConsoleInt(ICommandConsole console, string rawConsoleInt, out int i) { if (!int.TryParse(rawConsoleInt, out i)) { if (console != null) { console.Output("ERROR: {0} is not a valid integer", rawConsoleInt); } return(false); } return(true); }
/// <summary> /// Convert a console input to a bool, automatically complaining if a console is given. /// </summary> /// <param name='console'>Can be null if no console is available.</param> /// <param name='rawConsoleVector'>/param> /// <param name='vector'></param> /// <returns></returns> public static bool TryParseConsoleBool(ICommandConsole console, string rawConsoleString, out bool b) { if (!bool.TryParse(rawConsoleString, out b)) { if (console != null) { console.Output("ERROR: {0} is not a true or false value", rawConsoleString); } return(false); } return(true); }
public static bool TryParseConsoleLocalId(ICommandConsole console, string rawLocalId, out uint localId) { if (!uint.TryParse(rawLocalId, out localId)) { if (console != null) { console.Output("ERROR: {0} is not a valid local id", localId); } return(false); } if (localId == 0) { if (console != null) { console.Output("ERROR: {0} is not a valid local id - it must be greater than 0", localId); } return(false); } return(true); }
/// <summary> /// Convert a console integer to a natural int, automatically complaining if a console is given. /// </summary> /// <param name='console'>Can be null if no console is available.</param> /// <param name='rawConsoleInt'>/param> /// <param name='i'></param> /// <returns></returns> public static bool TryParseConsoleNaturalInt(ICommandConsole console, string rawConsoleInt, out int i) { if (TryParseConsoleInt(console, rawConsoleInt, out i)) { if (i < 0) { if (console != null) { console.Output("ERROR: {0} is not a positive integer", rawConsoleInt); } return(false); } return(true); } return(false); }
/// <summary> /// Tries to parse the input as either a UUID or a local ID. /// </summary> /// <returns>true if parsing succeeded, false otherwise.</returns> /// <param name='console'></param> /// <param name='rawId'></param> /// <param name='uuid'></param> /// <param name='localId'> /// Will be set to ConsoleUtil.LocalIdNotFound if parsing result was a UUID or no parse succeeded. /// </param> public static bool TryParseConsoleId(ICommandConsole console, string rawId, out UUID uuid, out uint localId) { if (TryParseConsoleUuid(null, rawId, out uuid)) { localId = LocalIdNotFound; return(true); } if (TryParseConsoleLocalId(null, rawId, out localId)) { return(true); } if (console != null) { console.Output("ERROR: {0} is not a valid UUID or local id", rawId); } return(false); }
public static void HandleStatsSaveCommand(string module, string[] cmd) { ICommandConsole con = MainConsole.Instance; if (cmd.Length != 3) { con.Output("Usage: stats save <path>"); return; } string path = cmd[2]; using (StreamWriter sw = new StreamWriter(path, true)) { foreach (string line in GetReport()) { sw.WriteLine(line); } } MainConsole.Instance.OutputFormat("Stats saved to file {0}", path); }
protected override void Append(LoggingEvent le) { if (m_console != null) { m_console.LockOutput(); } string loggingMessage = RenderLoggingEvent(le); try { if (m_console != null) { m_console.Output(loggingMessage, le.Level.Name); } else { if (!loggingMessage.EndsWith("\n")) { System.Console.WriteLine(loggingMessage); } else { System.Console.Write(loggingMessage); } } } catch (Exception e) { System.Console.WriteLine("Couldn't write out log message: {0}", e); } finally { if (m_console != null) { m_console.UnlockOutput(); } } }
/// <summary> /// Outputs the sogs to console. /// </summary> /// <param name='searchPredicate'></param> /// <param name='showFull'>If true then output all part details. If false then output summary.</param> private void OutputSogsToConsole(Predicate <SceneObjectGroup> searchPredicate, bool showFull) { List <SceneObjectGroup> sceneObjects = m_scene.GetSceneObjectGroups().FindAll(searchPredicate); StringBuilder sb = new StringBuilder(); foreach (SceneObjectGroup so in sceneObjects) { AddSceneObjectReport(sb, so, showFull); sb.Append("\n"); } sb.AppendFormat("{0} object(s) found in {1}\n", sceneObjects.Count, m_scene.Name); m_console.Output(sb.ToString()); }
private static void OutputCategoryStatsToConsole( ICommandConsole con, SortedDictionary<string, SortedDictionary<string, Stat>> category) { foreach (string report in GetCategoryStatsReports(category)) con.Output(report); }
private static void OutputContainerChecksToConsole(ICommandConsole con, SortedDictionary<string, Check> container) { foreach (Check check in container.Values) { con.Output(check.ToConsoleString()); } }
/// <summary> /// Shows help information on the console's Notice method /// </summary> public void ShowHelp(ICommandConsole console) { console.Output(String.Join(" ", m_cmdText) + " - " + m_helpText + "\n"); }
private static void OutputStatToConsole(ICommandConsole con, Stat stat) { con.Output(stat.ToConsoleString()); }
private static void OutputContainerStatsToConsole( ICommandConsole con, SortedDictionary<string, Stat> container) { foreach (string report in GetContainerStatsReports(container)) con.Output(report); }
private static void OutputContainerStatsToConsole( ICommandConsole con, SortedDictionary<string, Stat> container) { foreach (Stat stat in container.Values) { con.Output(stat.ToConsoleString()); } }
// AKIDO: remove this commented code // public static void RegisterConsoleCommands(ICommandConsole console) // { // console.Commands.AddCommand( // "General", // false, // "show stats", // "show stats [list|all|(<category>[.<container>])+", // "Show statistical information for this server", // "If no final argument is specified then legacy statistics information is currently shown.\n" // + "'list' argument will show statistic categories.\n" // + "'all' will show all statistics.\n" // + "A <category> name will show statistics from that category.\n" // + "A <category>.<container> name will show statistics from that category in that container.\n" // + "More than one name can be given separated by spaces.\n" // + "THIS STATS FACILITY IS EXPERIMENTAL AND DOES NOT YET CONTAIN ALL STATS", // HandleShowStatsCommand); // // StatsLogger.RegisterConsoleCommands(console); // } public static void HandleShowStatsCommand(string module, string[] cmd) { ICommandConsole con = MainConsole.Instance; if (cmd.Length > 2) { foreach (string name in cmd.Skip(2)) { string[] components = name.Split('.'); string categoryName = components[0]; string containerName = components.Length > 1 ? components[1] : null; if (categoryName == AllSubCommand) { OutputAllStatsToConsole(con); } else if (categoryName == ListSubCommand) { con.Output("Statistic categories available are:"); foreach (string category in RegisteredStats.Keys) { con.OutputFormat(" {0}", category); } } else { SortedDictionary <string, SortedDictionary <string, Stat> > category; if (!RegisteredStats.TryGetValue(categoryName, out category)) { con.OutputFormat("No such category as {0}", categoryName); } else { if (String.IsNullOrEmpty(containerName)) { OutputCategoryStatsToConsole(con, category); } else { SortedDictionary <string, Stat> container; if (category.TryGetValue(containerName, out container)) { OutputContainerStatsToConsole(con, container); } else { con.OutputFormat("No such container {0} in category {1}", containerName, categoryName); } } } } } } else { // Legacy if (SimExtraStats != null) { con.Output(SimExtraStats.Report()); } else { OutputAllStatsToConsole(con); } } }
private void HandleConsoleCommand(string module, string[] cmdparams) { ICommandConsole con = MainConsole.Instance; if (cmdparams.Length >= 2) { string cmd = cmdparams[1]; switch (cmd) { case "status": if (m_MemoryCacheEnabled) { con.OutputFormat("Memory Cache: {0} assets", m_MemoryCache.Count); } else { con.OutputFormat("Memory cache disabled"); } if (m_FileCacheEnabled) { int fileCount = GetFileCacheCount(m_CacheDirectory); con.OutputFormat("File Cache: {0} assets", fileCount); } else { con.Output("File cache disabled"); } GenerateCacheHitReport().ForEach(l => con.Output(l)); if (m_FileCacheEnabled) { con.Output("Deep scans have previously been performed on the following regions:"); foreach (string s in Directory.GetFiles(m_CacheDirectory, "*.fac")) { string RegionID = s.Remove(0, s.IndexOf("_")).Replace(".fac", ""); DateTime RegionDeepScanTMStamp = File.GetLastWriteTime(s); con.OutputFormat("Region: {0}, {1}", RegionID, RegionDeepScanTMStamp.ToString("MM/dd/yyyy hh:mm:ss")); } } break; case "clear": if (cmdparams.Length < 2) { con.Output("Usage is fcache clear [file] [memory]"); break; } bool clearMemory = false, clearFile = false; if (cmdparams.Length == 2) { clearMemory = true; clearFile = true; } foreach (string s in cmdparams) { if (s.ToLower() == "memory") { clearMemory = true; } else if (s.ToLower() == "file") { clearFile = true; } } if (clearMemory) { if (m_MemoryCacheEnabled) { m_MemoryCache.Clear(); con.Output("Memory cache cleared."); } else { con.Output("Memory cache not enabled."); } } if (clearFile) { if (m_FileCacheEnabled) { ClearFileCache(); con.Output("File cache cleared."); } else { con.Output("File cache not enabled."); } } break; case "assets": con.Output("Ensuring assets are cached for all scenes."); Watchdog.RunInThread(delegate { int assetReferenceTotal = TouchAllSceneAssets(true); con.OutputFormat("Completed check with {0} assets.", assetReferenceTotal); }, "TouchAllSceneAssets", null); break; case "expire": if (cmdparams.Length < 3) { con.OutputFormat("Invalid parameters for Expire, please specify a valid date & time", cmd); break; } string s_expirationDate = ""; DateTime expirationDate; if (cmdparams.Length > 3) { s_expirationDate = string.Join(" ", cmdparams, 2, cmdparams.Length - 2); } else { s_expirationDate = cmdparams[2]; } if (!DateTime.TryParse(s_expirationDate, out expirationDate)) { con.OutputFormat("{0} is not a valid date & time", cmd); break; } if (m_FileCacheEnabled) { CleanExpiredFiles(m_CacheDirectory, expirationDate); } else { con.OutputFormat("File cache not active, not clearing."); } break; default: con.OutputFormat("Unknown command {0}", cmd); break; } } else if (cmdparams.Length == 1) { con.Output("fcache assets - Attempt a deep cache of all assets in all scenes"); con.Output("fcache expire <datetime> - Purge assets older then the specified date & time"); con.Output("fcache clear [file] [memory] - Remove cached assets"); con.Output("fcache status - Display cache status"); } }
private static void OutputAllStatsToConsole(ICommandConsole con) { foreach (string report in GetAllStatsReports()) con.Output(report); }
private static void OutputCategoryStatsToConsole( ICommandConsole con, Dictionary<string, Dictionary<string, Stat>> category) { foreach (var container in category.Values) { foreach (Stat stat in container.Values) { con.Output(stat.ToConsoleString()); } } }