From f8fa76c09f379e2bd4b7b5bee96efb0288390602 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 9 Sep 2014 18:42:02 +0100 Subject: [PATCH] Add loglevel to jobengine that can be controlled via "debug jobengine loglevel ". Defaults to 0 Level 1 currently does verbose logging about every queued and processed job. --- OpenSim/Framework/Monitoring/JobEngine.cs | 32 ++++++++++++++++++----- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/OpenSim/Framework/Monitoring/JobEngine.cs b/OpenSim/Framework/Monitoring/JobEngine.cs index b401a5cbe3..ea2203f73e 100644 --- a/OpenSim/Framework/Monitoring/JobEngine.cs +++ b/OpenSim/Framework/Monitoring/JobEngine.cs @@ -52,6 +52,8 @@ namespace OpenSim.Framework.Monitoring { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + public int LogLevel { get; set; } + public bool IsRunning { get; private set; } /// @@ -186,7 +188,8 @@ namespace OpenSim.Framework.Monitoring public bool QueueRequest(string name, WaitCallback req, object o) { - m_log.DebugFormat("[JOB ENGINE]: Queued job {0}", name); + if (LogLevel >= 1) + m_log.DebugFormat("[JOB ENGINE]: Queued job {0}", name); if (m_requestQueue.Count < m_requestQueue.BoundedCapacity) { @@ -240,9 +243,14 @@ namespace OpenSim.Framework.Monitoring // } // } - m_log.DebugFormat("[JOB ENGINE]: Processing job {0}", m_currentJob.Name); + if (LogLevel >= 1) + m_log.DebugFormat("[JOB ENGINE]: Processing job {0}", m_currentJob.Name); + m_currentJob.Callback.Invoke(m_currentJob.O); - m_log.DebugFormat("[JOB ENGINE]: Processed job {0}", m_currentJob.Name); + + if (LogLevel >= 1) + m_log.DebugFormat("[JOB ENGINE]: Processed job {0}", m_currentJob.Name); + m_currentJob = null; } } @@ -258,9 +266,9 @@ namespace OpenSim.Framework.Monitoring // if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene) // return; - if (args.Length != 3) + if (args.Length < 3) { - MainConsole.Instance.Output("Usage: debug jobengine "); + MainConsole.Instance.Output("Usage: debug jobengine "); return; } @@ -282,6 +290,18 @@ namespace OpenSim.Framework.Monitoring MainConsole.Instance.OutputFormat("Current job {0}", m_currentJob != null ? m_currentJob.Name : "none"); MainConsole.Instance.OutputFormat( "Jobs waiting: {0}", IsRunning ? m_requestQueue.Count.ToString() : "n/a"); + MainConsole.Instance.OutputFormat("Log Level: {0}", LogLevel); + } + + else if (subCommand == "loglevel") + { +// int logLevel; + int logLevel = int.Parse(args[3]); +// if (ConsoleUtil.TryParseConsoleInt(MainConsole.Instance, args[4], out logLevel)) +// { + LogLevel = logLevel; + MainConsole.Instance.OutputFormat("Set log level to {0}", LogLevel); +// } } else { @@ -289,4 +309,4 @@ namespace OpenSim.Framework.Monitoring } } } -} \ No newline at end of file +}