From 54cf59ca438fe72eba6b6304f3fc4cf09ec80941 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Mon, 28 May 2007 22:20:25 +0000 Subject: Please to be testing new logdata interfaces! --- .../OpenGridServices.GridServer/GridManager.cs | 54 ++++++++++++++++++++-- 1 file changed, 51 insertions(+), 3 deletions(-) (limited to 'OpenGridServices/OpenGridServices.GridServer/GridManager.cs') diff --git a/OpenGridServices/OpenGridServices.GridServer/GridManager.cs b/OpenGridServices/OpenGridServices.GridServer/GridManager.cs index 54e4bb7..b73f24d 100644 --- a/OpenGridServices/OpenGridServices.GridServer/GridManager.cs +++ b/OpenGridServices/OpenGridServices.GridServer/GridManager.cs @@ -16,6 +16,8 @@ namespace OpenGridServices.GridServer class GridManager { Dictionary _plugins = new Dictionary(); + Dictionary _logplugins = new Dictionary(); + public OpenSim.Framework.Interfaces.GridConfig config; /// @@ -32,6 +34,7 @@ namespace OpenGridServices.GridServer { if (!pluginType.IsAbstract) { + // Regions go here Type typeInterface = pluginType.GetInterface("IGridData", true); if (typeInterface != null) @@ -43,12 +46,48 @@ namespace OpenGridServices.GridServer } typeInterface = null; + + // Logs go here + typeInterface = pluginType.GetInterface("ILogData", true); + + if (typeInterface != null) + { + ILogData plug = (ILogData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + plug.Initialise(); + this._logplugins.Add(plug.getName(), plug); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Storage: Added ILogData Interface"); + } + + typeInterface = null; } } pluginAssembly = null; } - + + /// + /// Logs a piece of information to the database + /// + /// What you were operating on (in grid server, this will likely be the region UUIDs) + /// Which method is being called? + /// What arguments are being passed? + /// How high priority is this? 1 = Max, 6 = Verbose + /// The message to log + private void logToDB(string target, string method, string args, int priority, string message) + { + foreach (KeyValuePair kvp in _logplugins) + { + try + { + kvp.Value.saveLog("Gridserver", target, method, args, priority, message); + } + catch (Exception e) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.NORMAL, "Storage: unable to write log via " + kvp.Key); + } + } + } + /// /// Returns a region by argument /// @@ -160,15 +199,23 @@ namespace OpenGridServices.GridServer if (requestData.ContainsKey("UUID")) { TheSim = getRegion(new LLUUID((string)requestData["UUID"])); + logToDB((new LLUUID((string)requestData["UUID"])).ToStringHyphenated(),"XmlRpcLoginToSimulatorMethod","", 5,"Region attempting login with UUID."); } else if (requestData.ContainsKey("region_handle")) { TheSim = getRegion((ulong)Convert.ToUInt64(requestData["region_handle"])); + logToDB((string)requestData["region_handle"], "XmlRpcLoginToSimulatorMethod", "", 5, "Region attempting login with regionHandle."); + } + else + { + responseData["error"] = "No UUID or region_handle passed to grid server - unable to connect you"; + return response; } if (TheSim == null) { responseData["error"] = "sim not found"; + return response; } else { @@ -366,7 +413,7 @@ namespace OpenGridServices.GridServer /// "OK" or an error public string RestSetSimMethod(string request, string path, string param) { - Console.WriteLine("SimProfiles.cs:RestSetSimMethod() - processing request......"); + Console.WriteLine("Processing region update"); SimProfileData TheSim; TheSim = getRegion(new LLUUID(param)); if ((TheSim) == null) @@ -449,13 +496,14 @@ namespace OpenGridServices.GridServer try { - OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Attempting to add a new region to the grid - " + _plugins.Count + " storage provider(s) registered."); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Updating / adding via " + _plugins.Count + " storage provider(s) registered."); foreach (KeyValuePair kvp in _plugins) { try { kvp.Value.AddProfile(TheSim); OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"New sim added to grid (" + TheSim.regionName + ")"); + logToDB(TheSim.UUID.ToStringHyphenated(), "RestSetSimMethod", "", 5, "Region successfully updated and connected to grid."); } catch (Exception e) { -- cgit v1.1