Added some logging

integration
BlueWall 2012-04-02 00:48:36 -04:00
parent 36daea4480
commit 335d167ead
3 changed files with 37 additions and 1 deletions

View File

@ -25,6 +25,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
using System;
using System.Reflection;
using OpenSim.Server.Base; using OpenSim.Server.Base;
using OpenSim.Services.Interfaces; using OpenSim.Services.Interfaces;
using OpenSim.Framework; using OpenSim.Framework;
@ -32,17 +34,19 @@ using OpenSim.Framework.Servers.HttpServer;
using GridRegion = OpenSim.Services.Interfaces.GridRegion; using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using OpenMetaverse; using OpenMetaverse;
using Nini.Config; using Nini.Config;
using log4net;
namespace OpenSim.Services.IntegrationService namespace OpenSim.Services.IntegrationService
{ {
public class IntegrationService : IntegrationServiceBase, IIntegrationService public class IntegrationService : IntegrationServiceBase, IIntegrationService
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public IntegrationService(IConfigSource config, IHttpServer server) public IntegrationService(IConfigSource config, IHttpServer server)
: base(config, server) : base(config, server)
{ {
m_log.InfoFormat("[IntegrationService]: Loaded");
} }

View File

@ -26,6 +26,7 @@
*/ */
using System; using System;
using System.IO;
using OpenSim.Services.Interfaces; using OpenSim.Services.Interfaces;
using OpenSim.Services.Base; using OpenSim.Services.Base;
using OpenSim.Framework.Servers.HttpServer; using OpenSim.Framework.Servers.HttpServer;
@ -34,6 +35,7 @@ using Nini.Config;
using OpenSim.Framework; using OpenSim.Framework;
using GridRegion = OpenSim.Services.Interfaces.GridRegion; using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using Mono.Addins; using Mono.Addins;
using log4net;
[assembly:AddinRoot ("IntegrationService", "1.0")] [assembly:AddinRoot ("IntegrationService", "1.0")]
@ -44,11 +46,14 @@ namespace OpenSim.Services.IntegrationService
public interface IntegrationPlugin public interface IntegrationPlugin
{ {
void Init(IConfigSource config); void Init(IConfigSource config);
string Name{ get; }
} }
public class IntegrationServiceBase : ServiceBase public class IntegrationServiceBase : ServiceBase
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected IPresenceService m_PresenceService; protected IPresenceService m_PresenceService;
protected IGridService m_GridService; protected IGridService m_GridService;
protected IHttpServer m_Server; protected IHttpServer m_Server;
@ -60,14 +65,20 @@ namespace OpenSim.Services.IntegrationService
Object[] args = new Object[] { config }; Object[] args = new Object[] { config };
AddinManager.AddinLoaded += on_addinloaded_;
m_Server = server; m_Server = server;
suppress_console_output_(true);
AddinManager.Initialize ("."); AddinManager.Initialize (".");
AddinManager.Registry.Update (); AddinManager.Registry.Update ();
suppress_console_output_(false);
foreach (IntegrationPlugin cmd in AddinManager.GetExtensionObjects("/OpenSim/IntegrationService")) foreach (IntegrationPlugin cmd in AddinManager.GetExtensionObjects("/OpenSim/IntegrationService"))
{ {
cmd.Init (config); cmd.Init (config);
server.AddStreamHandler((IRequestHandler)cmd); server.AddStreamHandler((IRequestHandler)cmd);
m_log.InfoFormat("[Integration]: Loading IntegrationService plugin {0}", cmd.Name);
} }
m_IntegrationServerConfig = config.Configs["IntegrationService"]; m_IntegrationServerConfig = config.Configs["IntegrationService"];
@ -87,5 +98,25 @@ namespace OpenSim.Services.IntegrationService
m_PresenceService = LoadPlugin<IPresenceService>(presenceService, args); m_PresenceService = LoadPlugin<IPresenceService>(presenceService, args);
} }
private void on_addinloaded_(object sender, AddinEventArgs args)
{
m_log.Info ("[IntegrationService]: Plugin Loaded: " + args.AddinId);
}
private static TextWriter prev_console_;
public void suppress_console_output_(bool save)
{
if (save)
{
prev_console_ = System.Console.Out;
System.Console.SetOut(new StreamWriter(Stream.Null));
}
else
{
if (prev_console_ != null)
System.Console.SetOut(prev_console_);
}
}
} }
} }

View File

@ -1169,6 +1169,7 @@
<Reference name="System.Xml"/> <Reference name="System.Xml"/>
<Reference name="OpenMetaverseTypes" path="../../../bin/"/> <Reference name="OpenMetaverseTypes" path="../../../bin/"/>
<Reference name="OpenMetaverse" path="../../../bin/"/> <Reference name="OpenMetaverse" path="../../../bin/"/>
<Reference name="OpenMetaverse.StructuredData" path="../../../bin/"/>
<Reference name="OpenSim.Framework"/> <Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Console"/> <Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Framework.Servers.HttpServer"/> <Reference name="OpenSim.Framework.Servers.HttpServer"/>