ServerBase.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections.Generic;
  29. using System.Diagnostics;
  30. using System.IO;
  31. using System.Reflection;
  32. using System.Text;
  33. using System.Text.RegularExpressions;
  34. using System.Threading;
  35. using log4net;
  36. using log4net.Appender;
  37. using log4net.Core;
  38. using log4net.Repository;
  39. using Nini.Config;
  40. using OpenSim.Framework.Console;
  41. using OpenSim.Framework.Monitoring;
  42. namespace OpenSim.Framework.Servers
  43. {
  44. public class ServerBase
  45. {
  46. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  47. public IConfigSource Config { get; protected set; }
  48. /// <summary>
  49. /// Console to be used for any command line output. Can be null, in which case there should be no output.
  50. /// </summary>
  51. protected ICommandConsole m_console;
  52. protected OpenSimAppender m_consoleAppender;
  53. protected FileAppender m_logFileAppender;
  54. protected DateTime m_startuptime;
  55. protected string m_startupDirectory = Environment.CurrentDirectory;
  56. protected string m_pidFile = String.Empty;
  57. /// <summary>
  58. /// Server version information. Usually VersionInfo + information about git commit, operating system, etc.
  59. /// </summary>
  60. protected string m_version;
  61. public ServerBase()
  62. {
  63. m_startuptime = DateTime.Now;
  64. m_version = VersionInfo.Version;
  65. EnhanceVersionInformation();
  66. }
  67. protected void CreatePIDFile(string path)
  68. {
  69. try
  70. {
  71. string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString();
  72. using (FileStream fs = File.Create(path))
  73. {
  74. Byte[] buf = Encoding.ASCII.GetBytes(pidstring);
  75. fs.Write(buf, 0, buf.Length);
  76. }
  77. m_pidFile = path;
  78. m_log.InfoFormat("[SERVER BASE]: Created pid file {0}", m_pidFile);
  79. }
  80. catch (Exception e)
  81. {
  82. m_log.Warn(string.Format("[SERVER BASE]: Could not create PID file at {0} ", path), e);
  83. }
  84. }
  85. protected void RemovePIDFile()
  86. {
  87. if (m_pidFile != String.Empty)
  88. {
  89. try
  90. {
  91. File.Delete(m_pidFile);
  92. }
  93. catch (Exception e)
  94. {
  95. m_log.Error(string.Format("[SERVER BASE]: Error whilst removing {0} ", m_pidFile), e);
  96. }
  97. m_pidFile = String.Empty;
  98. }
  99. }
  100. /// <summary>
  101. /// Log information about the circumstances in which we're running (OpenSimulator version number, CLR details,
  102. /// etc.).
  103. /// </summary>
  104. public void LogEnvironmentInformation()
  105. {
  106. // FIXME: This should be done down in ServerBase but we need to sort out and refactor the log4net
  107. // XmlConfigurator calls first accross servers.
  108. m_log.InfoFormat("[SERVER BASE]: Starting in {0}", m_startupDirectory);
  109. m_log.InfoFormat("[SERVER BASE]: OpenSimulator version: {0}", m_version);
  110. // clr version potentially is more confusing than helpful, since it doesn't tell us if we're running under Mono/MS .NET and
  111. // the clr version number doesn't match the project version number under Mono.
  112. //m_log.Info("[STARTUP]: Virtual machine runtime version: " + Environment.Version + Environment.NewLine);
  113. m_log.InfoFormat(
  114. "[SERVER BASE]: Operating system version: {0}, .NET platform {1}, {2}-bit",
  115. Environment.OSVersion, Environment.OSVersion.Platform, Util.Is64BitProcess() ? "64" : "32");
  116. }
  117. public void RegisterCommonAppenders(IConfig startupConfig)
  118. {
  119. ILoggerRepository repository = LogManager.GetRepository();
  120. IAppender[] appenders = repository.GetAppenders();
  121. foreach (IAppender appender in appenders)
  122. {
  123. if (appender.Name == "Console")
  124. {
  125. m_consoleAppender = (OpenSimAppender)appender;
  126. }
  127. else if (appender.Name == "LogFileAppender")
  128. {
  129. m_logFileAppender = (FileAppender)appender;
  130. }
  131. }
  132. if (null == m_consoleAppender)
  133. {
  134. Notice("No appender named Console found (see the log4net config file for this executable)!");
  135. }
  136. else
  137. {
  138. // FIXME: This should be done through an interface rather than casting.
  139. m_consoleAppender.Console = (ConsoleBase)m_console;
  140. // If there is no threshold set then the threshold is effectively everything.
  141. if (null == m_consoleAppender.Threshold)
  142. m_consoleAppender.Threshold = Level.All;
  143. Notice(String.Format("Console log level is {0}", m_consoleAppender.Threshold));
  144. }
  145. if (m_logFileAppender != null && startupConfig != null)
  146. {
  147. string cfgFileName = startupConfig.GetString("LogFile", null);
  148. if (cfgFileName != null)
  149. {
  150. m_logFileAppender.File = cfgFileName;
  151. m_logFileAppender.ActivateOptions();
  152. }
  153. m_log.InfoFormat("[SERVER BASE]: Logging started to file {0}", m_logFileAppender.File);
  154. }
  155. }
  156. /// <summary>
  157. /// Register common commands once m_console has been set if it is going to be set
  158. /// </summary>
  159. public void RegisterCommonCommands()
  160. {
  161. if (m_console == null)
  162. return;
  163. m_console.Commands.AddCommand(
  164. "General", false, "show info", "show info", "Show general information about the server", HandleShow);
  165. m_console.Commands.AddCommand(
  166. "General", false, "show version", "show version", "Show server version", HandleShow);
  167. m_console.Commands.AddCommand(
  168. "General", false, "show uptime", "show uptime", "Show server uptime", HandleShow);
  169. m_console.Commands.AddCommand(
  170. "General", false, "get log level", "get log level", "Get the current console logging level",
  171. (mod, cmd) => ShowLogLevel());
  172. m_console.Commands.AddCommand(
  173. "General", false, "set log level", "set log level <level>",
  174. "Set the console logging level for this session.", HandleSetLogLevel);
  175. m_console.Commands.AddCommand(
  176. "General", false, "config set",
  177. "config set <section> <key> <value>",
  178. "Set a config option. In most cases this is not useful since changed parameters are not dynamically reloaded. Neither do changed parameters persist - you will have to change a config file manually and restart.", HandleConfig);
  179. m_console.Commands.AddCommand(
  180. "General", false, "config get",
  181. "config get [<section>] [<key>]",
  182. "Synonym for config show",
  183. HandleConfig);
  184. m_console.Commands.AddCommand(
  185. "General", false, "config show",
  186. "config show [<section>] [<key>]",
  187. "Show config information",
  188. "If neither section nor field are specified, then the whole current configuration is printed." + Environment.NewLine
  189. + "If a section is given but not a field, then all fields in that section are printed.",
  190. HandleConfig);
  191. m_console.Commands.AddCommand(
  192. "General", false, "config save",
  193. "config save <path>",
  194. "Save current configuration to a file at the given path", HandleConfig);
  195. m_console.Commands.AddCommand(
  196. "General", false, "command-script",
  197. "command-script <script>",
  198. "Run a command script from file", HandleScript);
  199. m_console.Commands.AddCommand(
  200. "General", false, "show threads",
  201. "show threads",
  202. "Show thread status", HandleShow);
  203. m_console.Commands.AddCommand(
  204. "General", false, "threads abort",
  205. "threads abort <thread-id>",
  206. "Abort a managed thread. Use \"show threads\" to find possible threads.", HandleThreadsAbort);
  207. m_console.Commands.AddCommand(
  208. "General", false, "threads show",
  209. "threads show",
  210. "Show thread status. Synonym for \"show threads\"",
  211. (string module, string[] args) => Notice(GetThreadsReport()));
  212. m_console.Commands.AddCommand(
  213. "General", false, "force gc",
  214. "force gc",
  215. "Manually invoke runtime garbage collection. For debugging purposes",
  216. HandleForceGc);
  217. }
  218. private void HandleForceGc(string module, string[] args)
  219. {
  220. Notice("Manually invoking runtime garbage collection");
  221. GC.Collect();
  222. }
  223. public virtual void HandleShow(string module, string[] cmd)
  224. {
  225. List<string> args = new List<string>(cmd);
  226. args.RemoveAt(0);
  227. string[] showParams = args.ToArray();
  228. switch (showParams[0])
  229. {
  230. case "info":
  231. ShowInfo();
  232. break;
  233. case "version":
  234. Notice(GetVersionText());
  235. break;
  236. case "uptime":
  237. Notice(GetUptimeReport());
  238. break;
  239. case "threads":
  240. Notice(GetThreadsReport());
  241. break;
  242. }
  243. }
  244. /// <summary>
  245. /// Change and load configuration file data.
  246. /// </summary>
  247. /// <param name="module"></param>
  248. /// <param name="cmd"></param>
  249. private void HandleConfig(string module, string[] cmd)
  250. {
  251. List<string> args = new List<string>(cmd);
  252. args.RemoveAt(0);
  253. string[] cmdparams = args.ToArray();
  254. if (cmdparams.Length > 0)
  255. {
  256. string firstParam = cmdparams[0].ToLower();
  257. switch (firstParam)
  258. {
  259. case "set":
  260. if (cmdparams.Length < 4)
  261. {
  262. Notice("Syntax: config set <section> <key> <value>");
  263. Notice("Example: config set ScriptEngine.DotNetEngine NumberOfScriptThreads 5");
  264. }
  265. else
  266. {
  267. IConfig c;
  268. IConfigSource source = new IniConfigSource();
  269. c = source.AddConfig(cmdparams[1]);
  270. if (c != null)
  271. {
  272. string _value = String.Join(" ", cmdparams, 3, cmdparams.Length - 3);
  273. c.Set(cmdparams[2], _value);
  274. Config.Merge(source);
  275. Notice("In section [{0}], set {1} = {2}", c.Name, cmdparams[2], _value);
  276. }
  277. }
  278. break;
  279. case "get":
  280. case "show":
  281. if (cmdparams.Length == 1)
  282. {
  283. foreach (IConfig config in Config.Configs)
  284. {
  285. Notice("[{0}]", config.Name);
  286. string[] keys = config.GetKeys();
  287. foreach (string key in keys)
  288. Notice(" {0} = {1}", key, config.GetString(key));
  289. }
  290. }
  291. else if (cmdparams.Length == 2 || cmdparams.Length == 3)
  292. {
  293. IConfig config = Config.Configs[cmdparams[1]];
  294. if (config == null)
  295. {
  296. Notice("Section \"{0}\" does not exist.",cmdparams[1]);
  297. break;
  298. }
  299. else
  300. {
  301. if (cmdparams.Length == 2)
  302. {
  303. Notice("[{0}]", config.Name);
  304. foreach (string key in config.GetKeys())
  305. Notice(" {0} = {1}", key, config.GetString(key));
  306. }
  307. else
  308. {
  309. Notice(
  310. "config get {0} {1} : {2}",
  311. cmdparams[1], cmdparams[2], config.GetString(cmdparams[2]));
  312. }
  313. }
  314. }
  315. else
  316. {
  317. Notice("Syntax: config {0} [<section>] [<key>]", firstParam);
  318. Notice("Example: config {0} ScriptEngine.DotNetEngine NumberOfScriptThreads", firstParam);
  319. }
  320. break;
  321. case "save":
  322. if (cmdparams.Length < 2)
  323. {
  324. Notice("Syntax: config save <path>");
  325. return;
  326. }
  327. string path = cmdparams[1];
  328. Notice("Saving configuration file: {0}", path);
  329. if (Config is IniConfigSource)
  330. {
  331. IniConfigSource iniCon = (IniConfigSource)Config;
  332. iniCon.Save(path);
  333. }
  334. else if (Config is XmlConfigSource)
  335. {
  336. XmlConfigSource xmlCon = (XmlConfigSource)Config;
  337. xmlCon.Save(path);
  338. }
  339. break;
  340. }
  341. }
  342. }
  343. private void HandleSetLogLevel(string module, string[] cmd)
  344. {
  345. if (cmd.Length != 4)
  346. {
  347. Notice("Usage: set log level <level>");
  348. return;
  349. }
  350. if (null == m_consoleAppender)
  351. {
  352. Notice("No appender named Console found (see the log4net config file for this executable)!");
  353. return;
  354. }
  355. string rawLevel = cmd[3];
  356. ILoggerRepository repository = LogManager.GetRepository();
  357. Level consoleLevel = repository.LevelMap[rawLevel];
  358. if (consoleLevel != null)
  359. m_consoleAppender.Threshold = consoleLevel;
  360. else
  361. Notice(
  362. "{0} is not a valid logging level. Valid logging levels are ALL, DEBUG, INFO, WARN, ERROR, FATAL, OFF",
  363. rawLevel);
  364. ShowLogLevel();
  365. }
  366. private void ShowLogLevel()
  367. {
  368. Notice("Console log level is {0}", m_consoleAppender.Threshold);
  369. }
  370. protected virtual void HandleScript(string module, string[] parms)
  371. {
  372. if (parms.Length != 2)
  373. {
  374. Notice("Usage: command-script <path-to-script");
  375. return;
  376. }
  377. RunCommandScript(parms[1]);
  378. }
  379. /// <summary>
  380. /// Run an optional startup list of commands
  381. /// </summary>
  382. /// <param name="fileName"></param>
  383. protected void RunCommandScript(string fileName)
  384. {
  385. if (m_console == null)
  386. return;
  387. if (File.Exists(fileName))
  388. {
  389. m_log.Info("[SERVER BASE]: Running " + fileName);
  390. using (StreamReader readFile = File.OpenText(fileName))
  391. {
  392. string currentCommand;
  393. while ((currentCommand = readFile.ReadLine()) != null)
  394. {
  395. currentCommand = currentCommand.Trim();
  396. if (!(currentCommand == ""
  397. || currentCommand.StartsWith(";")
  398. || currentCommand.StartsWith("//")
  399. || currentCommand.StartsWith("#")))
  400. {
  401. m_log.Info("[SERVER BASE]: Running '" + currentCommand + "'");
  402. m_console.RunCommand(currentCommand);
  403. }
  404. }
  405. }
  406. }
  407. }
  408. /// <summary>
  409. /// Return a report about the uptime of this server
  410. /// </summary>
  411. /// <returns></returns>
  412. protected string GetUptimeReport()
  413. {
  414. StringBuilder sb = new StringBuilder(String.Format("Time now is {0}\n", DateTime.Now));
  415. sb.Append(String.Format("Server has been running since {0}, {1}\n", m_startuptime.DayOfWeek, m_startuptime));
  416. sb.Append(String.Format("That is an elapsed time of {0}\n", DateTime.Now - m_startuptime));
  417. return sb.ToString();
  418. }
  419. protected void ShowInfo()
  420. {
  421. Notice(GetVersionText());
  422. Notice("Startup directory: " + m_startupDirectory);
  423. if (null != m_consoleAppender)
  424. Notice(String.Format("Console log level: {0}", m_consoleAppender.Threshold));
  425. }
  426. /// <summary>
  427. /// Enhance the version string with extra information if it's available.
  428. /// </summary>
  429. protected void EnhanceVersionInformation()
  430. {
  431. string buildVersion = string.Empty;
  432. // The subversion information is deprecated and will be removed at a later date
  433. // Add subversion revision information if available
  434. // Try file "svn_revision" in the current directory first, then the .svn info.
  435. // This allows to make the revision available in simulators not running from the source tree.
  436. // FIXME: Making an assumption about the directory we're currently in - we do this all over the place
  437. // elsewhere as well
  438. string gitDir = "../.git/";
  439. string gitRefPointerPath = gitDir + "HEAD";
  440. string svnRevisionFileName = "svn_revision";
  441. string svnFileName = ".svn/entries";
  442. string manualVersionFileName = ".version";
  443. string inputLine;
  444. int strcmp;
  445. if (File.Exists(manualVersionFileName))
  446. {
  447. using (StreamReader CommitFile = File.OpenText(manualVersionFileName))
  448. buildVersion = CommitFile.ReadLine();
  449. m_version += buildVersion ?? "";
  450. }
  451. else if (File.Exists(gitRefPointerPath))
  452. {
  453. // m_log.DebugFormat("[SERVER BASE]: Found {0}", gitRefPointerPath);
  454. string rawPointer = "";
  455. using (StreamReader pointerFile = File.OpenText(gitRefPointerPath))
  456. rawPointer = pointerFile.ReadLine();
  457. // m_log.DebugFormat("[SERVER BASE]: rawPointer [{0}]", rawPointer);
  458. Match m = Regex.Match(rawPointer, "^ref: (.+)$");
  459. if (m.Success)
  460. {
  461. // m_log.DebugFormat("[SERVER BASE]: Matched [{0}]", m.Groups[1].Value);
  462. string gitRef = m.Groups[1].Value;
  463. string gitRefPath = gitDir + gitRef;
  464. if (File.Exists(gitRefPath))
  465. {
  466. // m_log.DebugFormat("[SERVER BASE]: Found gitRefPath [{0}]", gitRefPath);
  467. using (StreamReader refFile = File.OpenText(gitRefPath))
  468. {
  469. string gitHash = refFile.ReadLine();
  470. m_version += gitHash.Substring(0, 7);
  471. }
  472. }
  473. }
  474. }
  475. else
  476. {
  477. // Remove the else logic when subversion mirror is no longer used
  478. if (File.Exists(svnRevisionFileName))
  479. {
  480. StreamReader RevisionFile = File.OpenText(svnRevisionFileName);
  481. buildVersion = RevisionFile.ReadLine();
  482. buildVersion.Trim();
  483. RevisionFile.Close();
  484. }
  485. if (string.IsNullOrEmpty(buildVersion) && File.Exists(svnFileName))
  486. {
  487. StreamReader EntriesFile = File.OpenText(svnFileName);
  488. inputLine = EntriesFile.ReadLine();
  489. while (inputLine != null)
  490. {
  491. // using the dir svn revision at the top of entries file
  492. strcmp = String.Compare(inputLine, "dir");
  493. if (strcmp == 0)
  494. {
  495. buildVersion = EntriesFile.ReadLine();
  496. break;
  497. }
  498. else
  499. {
  500. inputLine = EntriesFile.ReadLine();
  501. }
  502. }
  503. EntriesFile.Close();
  504. }
  505. m_version += string.IsNullOrEmpty(buildVersion) ? " " : ("." + buildVersion + " ").Substring(0, 6);
  506. }
  507. }
  508. protected string GetVersionText()
  509. {
  510. return String.Format("Version: {0} (interface version {1})", m_version, VersionInfo.MajorInterfaceVersion);
  511. }
  512. /// <summary>
  513. /// Get a report about the registered threads in this server.
  514. /// </summary>
  515. protected string GetThreadsReport()
  516. {
  517. // This should be a constant field.
  518. string reportFormat = "{0,6} {1,35} {2,16} {3,13} {4,10} {5,30}";
  519. StringBuilder sb = new StringBuilder();
  520. Watchdog.ThreadWatchdogInfo[] threads = Watchdog.GetThreadsInfo();
  521. sb.Append(threads.Length + " threads are being tracked:" + Environment.NewLine);
  522. int timeNow = Environment.TickCount & Int32.MaxValue;
  523. sb.AppendFormat(reportFormat, "ID", "NAME", "LAST UPDATE (MS)", "LIFETIME (MS)", "PRIORITY", "STATE");
  524. sb.Append(Environment.NewLine);
  525. foreach (Watchdog.ThreadWatchdogInfo twi in threads)
  526. {
  527. Thread t = twi.Thread;
  528. sb.AppendFormat(
  529. reportFormat,
  530. t.ManagedThreadId,
  531. t.Name,
  532. timeNow - twi.LastTick,
  533. timeNow - twi.FirstTick,
  534. t.Priority,
  535. t.ThreadState);
  536. sb.Append("\n");
  537. }
  538. sb.Append("\n");
  539. // For some reason mono 2.6.7 returns an empty threads set! Not going to confuse people by reporting
  540. // zero active threads.
  541. int totalThreads = Process.GetCurrentProcess().Threads.Count;
  542. if (totalThreads > 0)
  543. sb.AppendFormat("Total threads active: {0}\n\n", totalThreads);
  544. sb.Append("Main threadpool (excluding script engine pools)\n");
  545. sb.Append(Util.GetThreadPoolReport());
  546. return sb.ToString();
  547. }
  548. public virtual void HandleThreadsAbort(string module, string[] cmd)
  549. {
  550. if (cmd.Length != 3)
  551. {
  552. MainConsole.Instance.Output("Usage: threads abort <thread-id>");
  553. return;
  554. }
  555. int threadId;
  556. if (!int.TryParse(cmd[2], out threadId))
  557. {
  558. MainConsole.Instance.Output("ERROR: Thread id must be an integer");
  559. return;
  560. }
  561. if (Watchdog.AbortThread(threadId))
  562. MainConsole.Instance.OutputFormat("Aborted thread with id {0}", threadId);
  563. else
  564. MainConsole.Instance.OutputFormat("ERROR - Thread with id {0} not found in managed threads", threadId);
  565. }
  566. /// <summary>
  567. /// Console output is only possible if a console has been established.
  568. /// That is something that cannot be determined within this class. So
  569. /// all attempts to use the console MUST be verified.
  570. /// </summary>
  571. /// <param name="msg"></param>
  572. protected void Notice(string msg)
  573. {
  574. if (m_console != null)
  575. {
  576. m_console.Output(msg);
  577. }
  578. }
  579. /// <summary>
  580. /// Console output is only possible if a console has been established.
  581. /// That is something that cannot be determined within this class. So
  582. /// all attempts to use the console MUST be verified.
  583. /// </summary>
  584. /// <param name="format"></param>
  585. /// <param name="components"></param>
  586. protected void Notice(string format, params object[] components)
  587. {
  588. if (m_console != null)
  589. m_console.OutputFormat(format, components);
  590. }
  591. }
  592. }