From 296c68a9de2d8253bdb88c67529619398d8ec6c9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 3 Mar 2010 18:28:30 +0000 Subject: Make the service loader pump out the error to the log (in red) and include the dll/interface/args that caused the problem This gives people more of a fighting chance of finding out what went wrong --- OpenSim/Services/Base/ServiceBase.cs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'OpenSim/Services/Base') diff --git a/OpenSim/Services/Base/ServiceBase.cs b/OpenSim/Services/Base/ServiceBase.cs index 8e24d85..91d5c56 100644 --- a/OpenSim/Services/Base/ServiceBase.cs +++ b/OpenSim/Services/Base/ServiceBase.cs @@ -26,7 +26,9 @@ */ using System; +using System.Collections.Generic; using System.Reflection; +using log4net; using Nini.Config; using OpenSim.Services.Interfaces; @@ -34,6 +36,8 @@ namespace OpenSim.Services.Base { public class ServiceBase { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + public T LoadPlugin(string dllName) where T:class { return LoadPlugin(dllName, new Object[0]); @@ -61,8 +65,12 @@ namespace OpenSim.Services.Base { Assembly pluginAssembly = Assembly.LoadFrom(dllName); +// m_log.DebugFormat("[SERVICE BASE]: Found assembly {0}", dllName); + foreach (Type pluginType in pluginAssembly.GetTypes()) { +// m_log.DebugFormat("[SERVICE BASE]: Found type {0}", pluginType); + if (pluginType.IsPublic) { if (className != String.Empty && @@ -86,7 +94,15 @@ namespace OpenSim.Services.Base } catch (Exception e) { - Console.WriteLine("XXX Exception " + e.StackTrace); + List strArgs = new List(); + foreach (Object arg in args) + strArgs.Add(arg.ToString()); + + m_log.Error( + string.Format( + "[SERVICE BASE]: Failed to load plugin {0} from {1} with args {2}", + interfaceName, dllName, string.Join(", ", strArgs.ToArray())), e); + return null; } } @@ -95,4 +111,4 @@ namespace OpenSim.Services.Base { } } -} +} \ No newline at end of file -- cgit v1.1