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 ++++++++++++++++++-- OpenSim/Services/Friends/FriendsServiceBase.cs | 9 ++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) (limited to 'OpenSim/Services') 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 diff --git a/OpenSim/Services/Friends/FriendsServiceBase.cs b/OpenSim/Services/Friends/FriendsServiceBase.cs index 9858972..6ab0bff 100644 --- a/OpenSim/Services/Friends/FriendsServiceBase.cs +++ b/OpenSim/Services/Friends/FriendsServiceBase.cs @@ -27,13 +27,12 @@ using System; using System.Reflection; +using log4net; using Nini.Config; using OpenSim.Framework; using OpenSim.Data; using OpenSim.Services.Interfaces; using OpenSim.Services.Base; -using Nini.Config; -using log4net; namespace OpenSim.Services.Friends { @@ -80,7 +79,11 @@ namespace OpenSim.Services.Friends m_Database = LoadPlugin(dllName, new Object[] { connString, realm }); if (m_Database == null) - throw new Exception("Could not find a storage interface in the given module"); + { + throw new Exception( + string.Format( + "Could not find a storage interface {0} in the given StorageProvider {1}", "IFriendsData", dllName)); + } } } } -- cgit v1.1