From 6ed5283bc06a62f38eb517e67b975832b603bf61 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Tue, 5 Feb 2008 19:44:27 +0000 Subject: Converted logging to use log4net. Changed LogBase to ConsoleBase, which handles console I/O. This is mostly an in-place conversion, so lots of refactoring can still be done. --- OpenSim/Grid/AssetServer/Main.cs | 46 ++++++++--------- OpenSim/Grid/AssetServer/RestService.cs | 23 +++++---- OpenSim/Grid/GridServer.Config/DbGridConfig.cs | 54 ++++++++++---------- OpenSim/Grid/GridServer/GridManager.cs | 59 +++++++++++----------- OpenSim/Grid/GridServer/Main.cs | 30 +++++------ .../Grid/InventoryServer/GridInventoryService.cs | 24 +++++---- OpenSim/Grid/InventoryServer/InventoryManager.cs | 16 +++--- OpenSim/Grid/InventoryServer/Main.cs | 22 ++++---- OpenSim/Grid/MessagingServer/Main.cs | 36 ++++++------- OpenSim/Grid/MessagingServer/MessageService.cs | 16 +++--- OpenSim/Grid/ScriptEngine/DotNetEngine/Common.cs | 7 ++- .../DotNetEngine/Compiler/LSL/LSL_BaseClass.cs | 4 +- .../Compiler/Server_API/LSL_BuiltIn_Commands.cs | 4 +- .../Grid/ScriptEngine/DotNetEngine/EventManager.cs | 8 +-- .../ScriptEngine/DotNetEngine/EventQueueManager.cs | 12 +++-- .../Grid/ScriptEngine/DotNetEngine/ScriptEngine.cs | 19 +++---- .../ScriptEngine/DotNetEngine/ScriptManager.cs | 8 +-- OpenSim/Grid/ScriptServer/Application.cs | 2 + .../ScriptServer/Region/RegionConnectionManager.cs | 4 +- .../ScriptServer/ScriptServer/RegionCommManager.cs | 7 +-- .../ScriptServer/ScriptEngineLoader.cs | 16 ++---- .../ScriptServer/ScriptEnginesManager.cs | 6 +-- OpenSim/Grid/ScriptServer/ScriptServerMain.cs | 23 ++++----- OpenSim/Grid/UserServer.Config/DbUserConfig.cs | 34 +++++++------ OpenSim/Grid/UserServer/Main.cs | 55 ++++++++++---------- OpenSim/Grid/UserServer/MessageServersConnector.cs | 16 +++--- OpenSim/Grid/UserServer/UserLoginService.cs | 42 +++++++-------- OpenSim/Grid/UserServer/UserManager.cs | 14 ++--- 28 files changed, 295 insertions(+), 312 deletions(-) (limited to 'OpenSim/Grid') diff --git a/OpenSim/Grid/AssetServer/Main.cs b/OpenSim/Grid/AssetServer/Main.cs index a95ea71..35e6495 100644 --- a/OpenSim/Grid/AssetServer/Main.cs +++ b/OpenSim/Grid/AssetServer/Main.cs @@ -43,6 +43,8 @@ namespace OpenSim.Grid.AssetServer /// public class OpenAsset_Main : BaseOpenSimServer, conscmd_callback { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + public AssetConfig m_config; public static OpenAsset_Main assetserver; @@ -55,7 +57,9 @@ namespace OpenSim.Grid.AssetServer [STAThread] public static void Main(string[] args) { - Console.WriteLine("Starting...\n"); + log4net.Config.XmlConfigurator.Configure(); + + m_log.Info("Starting...\n"); assetserver = new OpenAsset_Main(); assetserver.Startup(); @@ -65,42 +69,32 @@ namespace OpenSim.Grid.AssetServer private void Work() { - m_log.Notice("Enter help for a list of commands"); + m_console.Notice("Enter help for a list of commands"); while (true) { - m_log.MainLogPrompt(); + m_console.Prompt(); } } private OpenAsset_Main() { - if (!Directory.Exists(Util.logDir())) - { - Directory.CreateDirectory(Util.logDir()); - } - - m_log = - new LogBase( - (Path.Combine(Util.logDir(), "opengrid-AssetServer-console.log")), - "OpenAsset", - this, - true); + m_console = new ConsoleBase("OpenAsset", this); - MainLog.Instance = m_log; + MainConsole.Instance = m_console; } public void Startup() { m_config = new AssetConfig("ASSET SERVER", (Path.Combine(Util.configDir(), "AssetServer_Config.xml"))); - m_log.Verbose("ASSET", "Setting up asset DB"); + m_log.Info("[ASSET]: Setting up asset DB"); setupDB(m_config); - m_log.Verbose("ASSET", "Loading default asset set.."); + m_log.Info("[ASSET]: Loading default asset set.."); LoadDefaultAssets(); - m_log.Verbose("ASSET", "Starting HTTP process"); + m_log.Info("[ASSET]: Starting HTTP process"); BaseHttpServer httpServer = new BaseHttpServer(m_config.HttpPort); StatsManager.StartCollectingAssetStats(); @@ -118,7 +112,7 @@ namespace OpenSim.Grid.AssetServer public IAssetProvider LoadDatabasePlugin(string FileName) { - MainLog.Instance.Verbose("ASSET SERVER", "LoadDatabasePlugin: Attempting to load " + FileName); + m_log.Info("[ASSET SERVER]: LoadDatabasePlugin: Attempting to load " + FileName); Assembly pluginAssembly = Assembly.LoadFrom(FileName); IAssetProvider assetPlugin = null; foreach (Type pluginType in pluginAssembly.GetTypes()) @@ -134,7 +128,7 @@ namespace OpenSim.Grid.AssetServer assetPlugin = plug; assetPlugin.Initialise(); - MainLog.Instance.Verbose("ASSET SERVER", "Added " + assetPlugin.Name + " " + assetPlugin.Version); + m_log.Info("[ASSET SERVER]: Added " + assetPlugin.Name + " " + assetPlugin.Version); break; } @@ -153,14 +147,14 @@ namespace OpenSim.Grid.AssetServer m_assetProvider = LoadDatabasePlugin(config.DatabaseProvider); if (m_assetProvider == null) { - MainLog.Instance.Error("ASSET", "Failed to load a database plugin, server halting"); + m_log.Error("[ASSET]: Failed to load a database plugin, server halting"); Environment.Exit(-1); } } catch (Exception e) { - MainLog.Instance.Warn("ASSET", "setupDB() - Exception occured"); - MainLog.Instance.Warn("ASSET", e.ToString()); + m_log.Warn("[ASSET]: setupDB() - Exception occured"); + m_log.Warn("[ASSET]: " + e.ToString()); } } @@ -181,18 +175,18 @@ namespace OpenSim.Grid.AssetServer switch (cmd) { case "help": - m_log.Notice( + m_console.Notice( @"shutdown - shutdown this asset server (USE CAUTION!) stats - statistical information for this server"); break; case "stats": - m_log.Notice("STATS", Environment.NewLine + StatsManager.AssetStats.Report()); + m_console.Notice("STATS", Environment.NewLine + StatsManager.AssetStats.Report()); break; case "shutdown": - m_log.Close(); + m_console.Close(); Environment.Exit(0); break; } diff --git a/OpenSim/Grid/AssetServer/RestService.cs b/OpenSim/Grid/AssetServer/RestService.cs index 5c497b6..cb9e1ae 100644 --- a/OpenSim/Grid/AssetServer/RestService.cs +++ b/OpenSim/Grid/AssetServer/RestService.cs @@ -41,6 +41,8 @@ namespace OpenSim.Grid.AssetServer { public class GetAssetStreamHandler : BaseStreamHandler { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private OpenAsset_Main m_assetManager; private IAssetProvider m_assetProvider; @@ -52,7 +54,7 @@ namespace OpenSim.Grid.AssetServer public GetAssetStreamHandler(OpenAsset_Main assetManager, IAssetProvider assetProvider) : base("GET", "/assets") { - MainLog.Instance.Verbose("REST", "In Get Request"); + m_log.Info("[REST]: In Get Request"); m_assetManager = assetManager; m_assetProvider = assetProvider; } @@ -71,8 +73,8 @@ namespace OpenSim.Grid.AssetServer if (!LLUUID.TryParse(p[0], out assetID)) { - MainLog.Instance.Verbose( - "REST", "GET:/asset ignoring request with malformed UUID {0}", p[0]); + m_log.Info(String.Format( + "[REST]: GET:/asset ignoring request with malformed UUID {0}", p[0])); return result; } @@ -94,10 +96,9 @@ namespace OpenSim.Grid.AssetServer result = ms.GetBuffer(); - MainLog.Instance.Verbose( - "REST", - "GET:/asset found {0} with name {1}, size {2} bytes", - assetID, asset.Name, result.Length); + m_log.Info(String.Format( + "[REST]: GET:/asset found {0} with name {1}, size {2} bytes", + assetID, asset.Name, result.Length)); Array.Resize(ref result, (int) ms.Length); } @@ -106,13 +107,13 @@ namespace OpenSim.Grid.AssetServer if (StatsManager.AssetStats != null) StatsManager.AssetStats.AddNotFoundRequest(); - MainLog.Instance.Verbose("REST", "GET:/asset failed to find {0}", assetID); + m_log.Info(String.Format("[REST]: GET:/asset failed to find {0}", assetID)); } } } catch (Exception e) { - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); } return result; } @@ -120,6 +121,8 @@ namespace OpenSim.Grid.AssetServer public class PostAssetStreamHandler : BaseStreamHandler { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private OpenAsset_Main m_assetManager; private IAssetProvider m_assetProvider; @@ -135,7 +138,7 @@ namespace OpenSim.Grid.AssetServer XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); AssetBase asset = (AssetBase) xs.Deserialize(request); - MainLog.Instance.Verbose("REST", "StoreAndCommitAsset {0}", asset.FullID); + m_log.Info(String.Format("[REST]: StoreAndCommitAsset {0}", asset.FullID)); m_assetProvider.CreateAsset(asset); m_assetProvider.CommitAssets(); diff --git a/OpenSim/Grid/GridServer.Config/DbGridConfig.cs b/OpenSim/Grid/GridServer.Config/DbGridConfig.cs index e8225e1..5dde43d 100644 --- a/OpenSim/Grid/GridServer.Config/DbGridConfig.cs +++ b/OpenSim/Grid/GridServer.Config/DbGridConfig.cs @@ -38,13 +38,15 @@ namespace OpenGrid.Config.GridConfigDb4o /// public class Db40ConfigPlugin: IGridConfig { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + /// /// Loads and returns a configuration objeect /// /// A grid configuration object public GridConfig GetConfigObject() { - MainLog.Instance.Verbose("DBGRIDCONFIG", "Loading Db40Config dll"); + m_log.Info("[DBGRIDCONFIG]: Loading Db40Config dll"); return new DbGridConfig(); } } @@ -64,24 +66,24 @@ namespace OpenGrid.Config.GridConfigDb4o /// public void LoadDefaults() { - MainLog.Instance.Notice("DbGridConfig.cs:LoadDefaults() - Please press enter to retain default or enter new settings"); + MainConsole.Instance.Info("DbGridConfig.cs:LoadDefaults() - Please press enter to retain default or enter new settings"); // About the grid options - this.GridOwner = MainLog.Instance.CmdPrompt("Grid owner", "OGS development team"); + this.GridOwner = MainConsole.Instance.CmdPrompt("Grid owner", "OGS development team"); // Asset Options - this.DefaultAssetServer = MainLog.Instance.CmdPrompt("Default asset server","http://127.0.0.1:" + AssetConfig.DefaultHttpPort.ToString() + "/"); - this.AssetSendKey = MainLog.Instance.CmdPrompt("Key to send to asset server","null"); - this.AssetRecvKey = MainLog.Instance.CmdPrompt("Key to expect from asset server","null"); + this.DefaultAssetServer = MainConsole.Instance.CmdPrompt("Default asset server","http://127.0.0.1:" + AssetConfig.DefaultHttpPort.ToString() + "/"); + this.AssetSendKey = MainConsole.Instance.CmdPrompt("Key to send to asset server","null"); + this.AssetRecvKey = MainConsole.Instance.CmdPrompt("Key to expect from asset server","null"); // User Server Options - this.DefaultUserServer = MainLog.Instance.CmdPrompt("Default user server","http://127.0.0.1:" + UserConfig.DefaultHttpPort.ToString() + "/"); - this.UserSendKey = MainLog.Instance.CmdPrompt("Key to send to user server","null"); - this.UserRecvKey = MainLog.Instance.CmdPrompt("Key to expect from user server","null"); + this.DefaultUserServer = MainConsole.Instance.CmdPrompt("Default user server","http://127.0.0.1:" + UserConfig.DefaultHttpPort.ToString() + "/"); + this.UserSendKey = MainConsole.Instance.CmdPrompt("Key to send to user server","null"); + this.UserRecvKey = MainConsole.Instance.CmdPrompt("Key to expect from user server","null"); // Region Server Options - this.SimSendKey = MainLog.Instance.CmdPrompt("Key to send to sims","null"); - this.SimRecvKey = MainLog.Instance.CmdPrompt("Key to expect from sims","null"); + this.SimSendKey = MainConsole.Instance.CmdPrompt("Key to send to sims","null"); + this.SimRecvKey = MainConsole.Instance.CmdPrompt("Key to expect from sims","null"); } /// @@ -99,7 +101,7 @@ namespace OpenGrid.Config.GridConfigDb4o // Found? if (result.Count==1) { - MainLog.Instance.Verbose("DBGRIDCONFIG", "Found a GridConfig object in the local database, loading"); + m_log.Info("[DBGRIDCONFIG]: Found a GridConfig object in the local database, loading"); foreach (DbGridConfig cfg in result) { // Import each setting into this class @@ -121,13 +123,13 @@ namespace OpenGrid.Config.GridConfigDb4o } else { - MainLog.Instance.Verbose("DBGRIDCONFIG", "Could not find object in database, loading precompiled defaults"); + m_log.Info("[DBGRIDCONFIG]: Could not find object in database, loading precompiled defaults"); // Load default settings into this class LoadDefaults(); // Saves to the database file... - MainLog.Instance.Verbose("DBGRIDCONFIG", "Writing out default settings to local database"); + m_log.Info("[DBGRIDCONFIG]: Writing out default settings to local database"); db.Set(this); // Closes file locks @@ -136,27 +138,27 @@ namespace OpenGrid.Config.GridConfigDb4o } catch(Exception e) { - MainLog.Instance.Warn("DbGridConfig.cs:InitConfig() - Exception occured"); - MainLog.Instance.Warn(e.ToString()); + m_log.Warn("DbGridConfig.cs:InitConfig() - Exception occured"); + m_log.Warn(e.ToString()); } // Grid Settings - MainLog.Instance.Verbose("DBGRIDCONFIG", "Grid settings loaded:"); - MainLog.Instance.Verbose("DBGRIDCONFIG", "Grid owner: " + this.GridOwner); + m_log.Info("[DBGRIDCONFIG]: Grid settings loaded:"); + m_log.Info("[DBGRIDCONFIG]: Grid owner: " + this.GridOwner); // Asset Settings - MainLog.Instance.Verbose("DBGRIDCONFIG", "Default asset server: " + this.DefaultAssetServer); - MainLog.Instance.Verbose("DBGRIDCONFIG", "Key to send to asset server: " + this.AssetSendKey); - MainLog.Instance.Verbose("DBGRIDCONFIG", "Key to expect from asset server: " + this.AssetRecvKey); + m_log.Info("[DBGRIDCONFIG]: Default asset server: " + this.DefaultAssetServer); + m_log.Info("[DBGRIDCONFIG]: Key to send to asset server: " + this.AssetSendKey); + m_log.Info("[DBGRIDCONFIG]: Key to expect from asset server: " + this.AssetRecvKey); // User Settings - MainLog.Instance.Verbose("DBGRIDCONFIG", "Default user server: " + this.DefaultUserServer); - MainLog.Instance.Verbose("DBGRIDCONFIG", "Key to send to user server: " + this.UserSendKey); - MainLog.Instance.Verbose("DBGRIDCONFIG", "Key to expect from user server: " + this.UserRecvKey); + m_log.Info("[DBGRIDCONFIG]: Default user server: " + this.DefaultUserServer); + m_log.Info("[DBGRIDCONFIG]: Key to send to user server: " + this.UserSendKey); + m_log.Info("[DBGRIDCONFIG]: Key to expect from user server: " + this.UserRecvKey); // Region Settings - MainLog.Instance.Verbose("DBGRIDCONFIG", "Key to send to sims: " + this.SimSendKey); - MainLog.Instance.Verbose("DBGRIDCONFIG", "Key to expect from sims: " + this.SimRecvKey); + m_log.Info("[DBGRIDCONFIG]: Key to send to sims: " + this.SimSendKey); + m_log.Info("[DBGRIDCONFIG]: Key to expect from sims: " + this.SimRecvKey); } /// diff --git a/OpenSim/Grid/GridServer/GridManager.cs b/OpenSim/Grid/GridServer/GridManager.cs index c956a01..49b9aa2 100644 --- a/OpenSim/Grid/GridServer/GridManager.cs +++ b/OpenSim/Grid/GridServer/GridManager.cs @@ -38,11 +38,12 @@ using OpenSim.Framework.Console; using OpenSim.Framework.Data; using OpenSim.Framework.Servers; - namespace OpenSim.Grid.GridServer { internal class GridManager { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private Dictionary _plugins = new Dictionary(); private Dictionary _logplugins = new Dictionary(); @@ -57,10 +58,10 @@ namespace OpenSim.Grid.GridServer /// The filename to the grid server plugin DLL public void AddPlugin(string FileName) { - MainLog.Instance.Verbose("DATA", "Attempting to load " + FileName); + m_log.Info("[DATA]: Attempting to load " + FileName); Assembly pluginAssembly = Assembly.LoadFrom(FileName); - MainLog.Instance.Verbose("DATA", "Found " + pluginAssembly.GetTypes().Length + " interfaces."); + m_log.Info("[DATA]: Found " + pluginAssembly.GetTypes().Length + " interfaces."); foreach (Type pluginType in pluginAssembly.GetTypes()) { if (!pluginType.IsAbstract) @@ -74,7 +75,7 @@ namespace OpenSim.Grid.GridServer (IGridData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); plug.Initialise(); _plugins.Add(plug.getName(), plug); - MainLog.Instance.Verbose("DATA", "Added IGridData Interface"); + m_log.Info("[DATA]: Added IGridData Interface"); } typeInterface = null; @@ -88,7 +89,7 @@ namespace OpenSim.Grid.GridServer (ILogData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); plug.Initialise(); _logplugins.Add(plug.getName(), plug); - MainLog.Instance.Verbose("DATA", "Added ILogData Interface"); + m_log.Info("[DATA]: Added ILogData Interface"); } typeInterface = null; @@ -116,7 +117,7 @@ namespace OpenSim.Grid.GridServer } catch (Exception) { - MainLog.Instance.Warn("storage", "Unable to write log via " + kvp.Key); + m_log.Warn("[storage]: Unable to write log via " + kvp.Key); } } } @@ -136,7 +137,7 @@ namespace OpenSim.Grid.GridServer } catch (Exception e) { - MainLog.Instance.Warn("storage", "getRegion - " + e.Message); + m_log.Warn("[storage]: getRegion - " + e.Message); } } return null; @@ -157,7 +158,7 @@ namespace OpenSim.Grid.GridServer } catch { - MainLog.Instance.Warn("storage", "Unable to find region " + handle.ToString() + " via " + kvp.Key); + m_log.Warn("[storage]: Unable to find region " + handle.ToString() + " via " + kvp.Key); } } return null; @@ -179,7 +180,7 @@ namespace OpenSim.Grid.GridServer } catch { - MainLog.Instance.Warn("storage", "Unable to query regionblock via " + kvp.Key); + m_log.Warn("[storage]: Unable to query regionblock via " + kvp.Key); } } @@ -245,14 +246,14 @@ namespace OpenSim.Grid.GridServer } else { - MainLog.Instance.Verbose("GRID", "Region connected without a UUID, ignoring."); + m_log.Info("[GRID]: Region connected without a UUID, ignoring."); responseData["error"] = "No UUID passed to grid server - unable to connect you"; return response; } if (TheSim == null) // Shouldnt this be in the REST Simulator Set method? { - MainLog.Instance.Verbose("GRID", "New region connecting"); + m_log.Info("[GRID]: New region connecting"); myword = "creation"; } else @@ -320,7 +321,7 @@ namespace OpenSim.Grid.GridServer (OldSim.regionRecvKey == TheSim.regionRecvKey && OldSim.regionSendKey == TheSim.regionSendKey)) { - MainLog.Instance.Verbose("GRID", "Adding region " + TheSim.regionLocX + " , " + TheSim.regionLocY + " , " + + m_log.Info("[GRID]: Adding region " + TheSim.regionLocX + " , " + TheSim.regionLocY + " , " + TheSim.serverURI); foreach (KeyValuePair kvp in _plugins) { @@ -330,17 +331,17 @@ namespace OpenSim.Grid.GridServer switch (insertResponse) { case DataResponse.RESPONSE_OK: - MainLog.Instance.Verbose("grid", "New sim " + myword + " successful: " + TheSim.regionName); + m_log.Info("[grid]: New sim " + myword + " successful: " + TheSim.regionName); break; case DataResponse.RESPONSE_ERROR: - MainLog.Instance.Warn("storage", "New sim creation failed (Error): " + TheSim.regionName); + m_log.Warn("[storage]: New sim creation failed (Error): " + TheSim.regionName); break; case DataResponse.RESPONSE_INVALIDCREDENTIALS: - MainLog.Instance.Warn("storage", + m_log.Warn("[storage]: " + "New sim creation failed (Invalid Credentials): " + TheSim.regionName); break; case DataResponse.RESPONSE_AUTHREQUIRED: - MainLog.Instance.Warn("storage", + m_log.Warn("[storage]: " + "New sim creation failed (Authentication Required): " + TheSim.regionName); break; @@ -348,9 +349,9 @@ namespace OpenSim.Grid.GridServer } catch (Exception e) { - MainLog.Instance.Warn("storage", + m_log.Warn("[storage]: " + "Unable to add region " + TheSim.UUID.ToString() + " via " + kvp.Key); - MainLog.Instance.Warn("storage", e.ToString()); + m_log.Warn("[storage]: " + e.ToString()); } @@ -458,14 +459,14 @@ namespace OpenSim.Grid.GridServer } else { - MainLog.Instance.Warn("grid", "Authentication failed when trying to add new region " + TheSim.regionName + " at location " + TheSim.regionLocX + " " + TheSim.regionLocY + " currently occupied by " + OldSim.regionName); + m_log.Warn("[grid]: Authentication failed when trying to add new region " + TheSim.regionName + " at location " + TheSim.regionLocX + " " + TheSim.regionLocY + " currently occupied by " + OldSim.regionName); responseData["error"] = "The key required to connect to your region did not match. Please check your send and recieve keys."; return response; } } else { - MainLog.Instance.Warn("grid", "Failed to add new region " + TheSim.regionName + " at location " + TheSim.regionLocX + " " + TheSim.regionLocY + " currently occupied by " + OldSim.regionName); + m_log.Warn("[grid]: Failed to add new region " + TheSim.regionName + " at location " + TheSim.regionLocX + " " + TheSim.regionLocY + " currently occupied by " + OldSim.regionName); responseData["error"] = "Another region already exists at that location. Try another"; return response; } @@ -496,7 +497,7 @@ namespace OpenSim.Grid.GridServer } else { - MainLog.Instance.Verbose("DATA", "found " + (string) simData.regionName + " regionHandle = " + + m_log.Info("[DATA]: found " + (string) simData.regionName + " regionHandle = " + (string) requestData["region_handle"]); responseData["sim_ip"] = Util.GetHostFromDNS(simData.serverIP).ToString(); responseData["sim_port"] = simData.serverPort.ToString(); @@ -535,8 +536,8 @@ namespace OpenSim.Grid.GridServer { ymax = (Int32) requestData["ymax"]; } - //CFK: The second MainLog is more meaningful and either standard or fast generally occurs. - //CFK: MainLog.Instance.Verbose("MAP", "World map request for range (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")"); + //CFK: The second log is more meaningful and either standard or fast generally occurs. + //CFK: m_log.Info("[MAP]: World map request for range (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")"); XmlRpcResponse response = new XmlRpcResponse(); Hashtable responseData = new Hashtable(); @@ -575,7 +576,7 @@ namespace OpenSim.Grid.GridServer simProfileList.Add(simProfileBlock); } - MainLog.Instance.Verbose("MAP", "Fast map " + simProfileList.Count.ToString() + + m_log.Info("[MAP]: Fast map " + simProfileList.Count.ToString() + " regions @ (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")"); } else @@ -610,7 +611,7 @@ namespace OpenSim.Grid.GridServer } } } - MainLog.Instance.Verbose("MAP", "Std map " + simProfileList.Count.ToString() + + m_log.Info("[MAP]: Std map " + simProfileList.Count.ToString() + " regions @ (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")"); } @@ -776,7 +777,7 @@ namespace OpenSim.Grid.GridServer try { - MainLog.Instance.Verbose("DATA", + m_log.Info("[DATA]: " + "Updating / adding via " + _plugins.Count + " storage provider(s) registered."); foreach (KeyValuePair kvp in _plugins) { @@ -789,13 +790,13 @@ namespace OpenSim.Grid.GridServer (reserveData == null && authkeynode.InnerText != TheSim.regionRecvKey)) { kvp.Value.AddProfile(TheSim); - MainLog.Instance.Verbose("grid", "New sim added to grid (" + TheSim.regionName + ")"); + m_log.Info("[grid]: New sim added to grid (" + TheSim.regionName + ")"); logToDB(TheSim.UUID.ToString(), "RestSetSimMethod", String.Empty, 5, "Region successfully updated and connected to grid."); } else { - MainLog.Instance.Warn("grid", + m_log.Warn("[grid]: " + "Unable to update region (RestSetSimMethod): Incorrect reservation auth key."); // Wanted: " + reserveData.gridRecvKey + ", Got: " + TheSim.regionRecvKey + "."); return "Unable to update region (RestSetSimMethod): Incorrect auth key."; @@ -803,7 +804,7 @@ namespace OpenSim.Grid.GridServer } catch (Exception e) { - MainLog.Instance.Warn("GRID", "getRegionPlugin Handle " + kvp.Key + " unable to add new sim: " + + m_log.Warn("[GRID]: getRegionPlugin Handle " + kvp.Key + " unable to add new sim: " + e.ToString()); } } diff --git a/OpenSim/Grid/GridServer/Main.cs b/OpenSim/Grid/GridServer/Main.cs index 8a522c2..ff4a888 100644 --- a/OpenSim/Grid/GridServer/Main.cs +++ b/OpenSim/Grid/GridServer/Main.cs @@ -39,6 +39,8 @@ namespace OpenSim.Grid.GridServer /// public class OpenGrid_Main : BaseOpenSimServer, conscmd_callback { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + public GridConfig Cfg; public static OpenGrid_Main thegrid; @@ -54,11 +56,13 @@ namespace OpenSim.Grid.GridServer [STAThread] public static void Main(string[] args) { + log4net.Config.XmlConfigurator.Configure(); + if (args.Length > 0) { if (args[0] == "-setuponly") setuponly = true; } - Console.WriteLine("Starting...\n"); + m_log.Info("Starting...\n"); thegrid = new OpenGrid_Main(); thegrid.Startup(); @@ -68,23 +72,18 @@ namespace OpenSim.Grid.GridServer private void Work() { - m_log.Notice("Enter help for a list of commands\n"); + m_console.Notice("Enter help for a list of commands\n"); while (true) { - m_log.MainLogPrompt(); + m_console.Prompt(); } } private OpenGrid_Main() { - if (!Directory.Exists(Util.logDir())) - { - Directory.CreateDirectory(Util.logDir()); - } - m_log = - new LogBase((Path.Combine(Util.logDir(), "opengrid-gridserver-console.log")), "OpenGrid", this, true); - MainLog.Instance = m_log; + m_console = new ConsoleBase("OpenGrid", this); + MainConsole.Instance = m_console; } public void managercallback(string cmd) @@ -97,19 +96,18 @@ namespace OpenSim.Grid.GridServer } } - public void Startup() { Cfg = new GridConfig("GRID SERVER", (Path.Combine(Util.configDir(), "GridServer_Config.xml"))); //Yeah srsly, that's it. if (setuponly) Environment.Exit(0); - m_log.Verbose("GRID", "Connecting to Storage Server"); + m_log.Info("[GRID]: Connecting to Storage Server"); m_gridManager = new GridManager(); m_gridManager.AddPlugin(Cfg.DatabaseProvider); // Made of win m_gridManager.config = Cfg; - m_log.Verbose("GRID", "Starting HTTP process"); + m_log.Info("[GRID]: Starting HTTP process"); BaseHttpServer httpServer = new BaseHttpServer(Cfg.HttpPort); //GridManagementAgent GridManagerAgent = new GridManagementAgent(httpServer, "gridserver", Cfg.SimSendKey, Cfg.SimRecvKey, managercallback); @@ -135,7 +133,7 @@ namespace OpenSim.Grid.GridServer httpServer.Start(); - m_log.Verbose("GRID", "Starting sim status checker"); + m_log.Info("[GRID]: Starting sim status checker"); Timer simCheckTimer = new Timer(3600000*3); // 3 Hours between updates. simCheckTimer.Elapsed += new ElapsedEventHandler(CheckSims); @@ -186,11 +184,11 @@ namespace OpenSim.Grid.GridServer switch (cmd) { case "help": - m_log.Notice("shutdown - shutdown the grid (USE CAUTION!)"); + m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)"); break; case "shutdown": - m_log.Close(); + m_console.Close(); Environment.Exit(0); break; } diff --git a/OpenSim/Grid/InventoryServer/GridInventoryService.cs b/OpenSim/Grid/InventoryServer/GridInventoryService.cs index d36a915..a719452 100644 --- a/OpenSim/Grid/InventoryServer/GridInventoryService.cs +++ b/OpenSim/Grid/InventoryServer/GridInventoryService.cs @@ -37,6 +37,8 @@ namespace OpenSim.Grid.InventoryServer { public class GridInventoryService : InventoryServiceBase { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + public override void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack) { @@ -108,7 +110,7 @@ namespace OpenSim.Grid.InventoryServer LLUUID userID = new LLUUID(rawUserID); // We get enough verbose messages later on for diagnostics - //MainLog.Instance.Verbose("INVENTORY", "Request for inventory for " + userID.ToString()); + //m_log.Info("[INVENTORY]: Request for inventory for " + userID.ToString()); InventoryCollection invCollection = new InventoryCollection(); List folders; @@ -126,8 +128,8 @@ namespace OpenSim.Grid.InventoryServer { LLUUID userID = new LLUUID(rawUserID); - MainLog.Instance.Verbose( - "INVENTORY", "Creating new set of inventory folders for " + userID.ToString()); + m_log.Info( + "[INVENTORY]: Creating new set of inventory folders for " + userID.ToString()); CreateNewUserInventory(userID); return true; @@ -152,8 +154,8 @@ namespace OpenSim.Grid.InventoryServer public bool AddInventoryFolder(InventoryFolderBase folder) { // Right now, this actions act more like an update/insert combination than a simple create. - MainLog.Instance.Verbose( - "INVENTORY", + m_log.Info( + "[INVENTORY]: " + "Updating in " + folder.parentID.ToString() + ", folder " + folder.name); @@ -163,8 +165,8 @@ namespace OpenSim.Grid.InventoryServer public bool MoveInventoryFolder(InventoryFolderBase folder) { - MainLog.Instance.Verbose( - "INVENTORY", + m_log.Info( + "[INVENTORY]: " + "Moving folder " + folder.folderID + " to " + folder.parentID.ToString()); @@ -175,8 +177,8 @@ namespace OpenSim.Grid.InventoryServer public bool AddInventoryItem(InventoryItemBase item) { // Right now, this actions act more like an update/insert combination than a simple create. - MainLog.Instance.Verbose( - "INVENTORY", + m_log.Info( + "[INVENTORY]: " + "Updating in " + item.parentFolderID.ToString() + ", item " + item.inventoryName); @@ -187,8 +189,8 @@ namespace OpenSim.Grid.InventoryServer public override void DeleteInventoryItem(LLUUID userID, InventoryItemBase item) { // extra spaces to align with other inventory messages - MainLog.Instance.Verbose( - "INVENTORY", + m_log.Info( + "[INVENTORY]: " + "Deleting in " + item.parentFolderID.ToString() + ", item " + item.inventoryName); diff --git a/OpenSim/Grid/InventoryServer/InventoryManager.cs b/OpenSim/Grid/InventoryServer/InventoryManager.cs index 6ca5064..35b66b2 100644 --- a/OpenSim/Grid/InventoryServer/InventoryManager.cs +++ b/OpenSim/Grid/InventoryServer/InventoryManager.cs @@ -41,6 +41,8 @@ namespace OpenSim.Grid.InventoryServer { public class InventoryManager { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private IInventoryData _databasePlugin; /// @@ -49,10 +51,10 @@ namespace OpenSim.Grid.InventoryServer /// The filename to the inventory server plugin DLL public void AddDatabasePlugin(string FileName) { - MainLog.Instance.Verbose(OpenInventory_Main.LogName, "Invenstorage: Attempting to load " + FileName); + m_log.Info("[" + OpenInventory_Main.LogName + "]: Invenstorage: Attempting to load " + FileName); Assembly pluginAssembly = Assembly.LoadFrom(FileName); - MainLog.Instance.Verbose(OpenInventory_Main.LogName, + m_log.Info("[" + OpenInventory_Main.LogName + "]: " + "Invenstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces."); foreach (Type pluginType in pluginAssembly.GetTypes()) { @@ -66,7 +68,7 @@ namespace OpenSim.Grid.InventoryServer (IInventoryData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); plug.Initialise(); _databasePlugin = plug; - MainLog.Instance.Verbose(OpenInventory_Main.LogName, + m_log.Info("[" + OpenInventory_Main.LogName + "]: " + "Invenstorage: Added IInventoryData Interface"); break; } @@ -156,7 +158,7 @@ namespace OpenSim.Grid.InventoryServer saveInventoryToStream(_inventory, fs); fs.Flush(); fs.Close(); - MainLog.Instance.Debug(OpenInventory_Main.LogName, "Modified"); + m_log.Debug("[" + OpenInventory_Main.LogName + "]: Modified"); } } @@ -166,14 +168,14 @@ namespace OpenSim.Grid.InventoryServer private byte[] GetUserInventory(LLUUID userID) { - MainLog.Instance.Notice(OpenInventory_Main.LogName, "Getting Inventory for user {0}", userID.ToString()); + m_log.Info(String.Format("[" + OpenInventory_Main.LogName + "]: Getting Inventory for user {0}", userID.ToString())); byte[] result = new byte[] {}; InventoryFolderBase fb = _manager._databasePlugin.getUserRootFolder(userID); if (fb == null) { - MainLog.Instance.Notice(OpenInventory_Main.LogName, "Inventory not found for user {0}, creating new", - userID.ToString()); + m_log.Info(String.Format("[" + OpenInventory_Main.LogName + "]: Inventory not found for user {0}, creating new", + userID.ToString())); CreateDefaultInventory(userID); } diff --git a/OpenSim/Grid/InventoryServer/Main.cs b/OpenSim/Grid/InventoryServer/Main.cs index b62c696..5037c7d 100644 --- a/OpenSim/Grid/InventoryServer/Main.cs +++ b/OpenSim/Grid/InventoryServer/Main.cs @@ -38,6 +38,8 @@ namespace OpenSim.Grid.InventoryServer { public class OpenInventory_Main : BaseOpenSimServer, conscmd_callback { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private InventoryManager m_inventoryManager; private InventoryConfig m_config; private GridInventoryService m_inventoryService; @@ -47,6 +49,8 @@ namespace OpenSim.Grid.InventoryServer [STAThread] public static void Main(string[] args) { + log4net.Config.XmlConfigurator.Configure(); + OpenInventory_Main theServer = new OpenInventory_Main(); theServer.Startup(); @@ -55,20 +59,20 @@ namespace OpenSim.Grid.InventoryServer public OpenInventory_Main() { - m_log = new LogBase("opengrid-inventory-console.log", LogName, this, true); - MainLog.Instance = m_log; + m_console = new ConsoleBase(LogName, this); + MainConsole.Instance = m_console; } public void Startup() { - MainLog.Instance.Notice("Initialising inventory manager..."); + m_log.Info("Initialising inventory manager..."); m_config = new InventoryConfig(LogName, (Path.Combine(Util.configDir(), "InventoryServer_Config.xml"))); m_inventoryService = new GridInventoryService(); // m_inventoryManager = new InventoryManager(); m_inventoryService.AddPlugin(m_config.DatabaseProvider); - MainLog.Instance.Notice(LogName, "Starting HTTP server ..."); + m_log.Info("[" + LogName + "]: Starting HTTP server ..."); BaseHttpServer httpServer = new BaseHttpServer(m_config.HttpPort); httpServer.AddStreamHandler( new RestDeserialisehandler("POST", "/GetInventory/", @@ -95,19 +99,19 @@ namespace OpenSim.Grid.InventoryServer new RestDeserialisehandler>("POST", "/RootFolders/", m_inventoryService.RequestFirstLevelFolders)); - // httpServer.AddStreamHandler(new InventoryManager.GetInventory(m_inventoryManager)); + // httpServer.AddStreamHandler(new InventoryManager.GetInventory(m_inventoryManager)); httpServer.Start(); - MainLog.Instance.Notice(LogName, "Started HTTP server"); + m_log.Info("[" + LogName + "]: Started HTTP server"); } private void Work() { - m_log.Notice("Enter help for a list of commands\n"); + m_console.Notice("Enter help for a list of commands\n"); while (true) { - m_log.MainLogPrompt(); + m_console.Prompt(); } } @@ -122,7 +126,7 @@ namespace OpenSim.Grid.InventoryServer m_inventoryService.CreateUsersInventory(LLUUID.Random().UUID); break; case "shutdown": - m_log.Close(); + m_console.Close(); Environment.Exit(0); break; } diff --git a/OpenSim/Grid/MessagingServer/Main.cs b/OpenSim/Grid/MessagingServer/Main.cs index 3d5ceb4..c16b0f8 100644 --- a/OpenSim/Grid/MessagingServer/Main.cs +++ b/OpenSim/Grid/MessagingServer/Main.cs @@ -41,6 +41,8 @@ namespace OpenSim.Grid.MessagingServer /// public class OpenMessage_Main : BaseOpenSimServer, conscmd_callback { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private MessageServerConfig Cfg; //public UserManager m_userManager; @@ -51,7 +53,9 @@ namespace OpenSim.Grid.MessagingServer [STAThread] public static void Main(string[] args) { - Console.WriteLine("Launching MessagingServer..."); + log4net.Config.XmlConfigurator.Configure(); + + m_log.Info("Launching MessagingServer..."); OpenMessage_Main messageserver = new OpenMessage_Main(); @@ -61,22 +65,17 @@ namespace OpenSim.Grid.MessagingServer private OpenMessage_Main() { - if (!Directory.Exists(Util.logDir())) - { - Directory.CreateDirectory(Util.logDir()); - } - m_log = - new LogBase((Path.Combine(Util.logDir(), "opengrid-messagingserver-console.log")), "OpenMessage", this, true); - MainLog.Instance = m_log; + m_console = new ConsoleBase("OpenMessage", this); + MainConsole.Instance = m_console; } private void Work() { - m_log.Notice("Enter help for a list of commands\n"); + m_console.Notice("Enter help for a list of commands\n"); while (true) { - m_log.MainLogPrompt(); + m_console.Prompt(); } } @@ -84,9 +83,7 @@ namespace OpenSim.Grid.MessagingServer { Cfg = new MessageServerConfig("MESSAGING SERVER", (Path.Combine(Util.configDir(), "MessagingServer_Config.xml"))); - - - MainLog.Instance.Verbose("REGION", "Starting HTTP process"); + m_log.Info("[REGION]: Starting HTTP process"); BaseHttpServer httpServer = new BaseHttpServer(Cfg.HttpPort); //httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod); @@ -104,10 +101,9 @@ namespace OpenSim.Grid.MessagingServer //new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod)); httpServer.Start(); - m_log.Status("SERVER", "Messageserver 0.4 - Startup complete"); + m_log.Info("[SERVER]: Messageserver 0.4 - Startup complete"); } - public void do_create(string what) { switch (what) @@ -120,7 +116,7 @@ namespace OpenSim.Grid.MessagingServer //m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY); } catch (Exception ex) { - m_log.Error("SERVER", "Error creating user: {0}", ex.ToString()); + m_console.Error("[SERVER]: Error creating user: {0}", ex.ToString()); } try @@ -130,9 +126,9 @@ namespace OpenSim.Grid.MessagingServer } catch (Exception ex) { - m_log.Error("SERVER", "Error creating inventory for user: {0}", ex.ToString()); + m_console.Error("[SERVER]: Error creating inventory for user: {0}", ex.ToString()); } - // m_lastCreatedUser = userID; + // m_lastCreatedUser = userID; break; } } @@ -144,11 +140,11 @@ namespace OpenSim.Grid.MessagingServer switch (cmd) { case "help": - m_log.Notice("shutdown - shutdown the message server (USE CAUTION!)"); + m_console.Notice("shutdown - shutdown the message server (USE CAUTION!)"); break; case "shutdown": - m_log.Close(); + m_console.Close(); Environment.Exit(0); break; } diff --git a/OpenSim/Grid/MessagingServer/MessageService.cs b/OpenSim/Grid/MessagingServer/MessageService.cs index 056bfcb..c2669b0 100644 --- a/OpenSim/Grid/MessagingServer/MessageService.cs +++ b/OpenSim/Grid/MessagingServer/MessageService.cs @@ -43,7 +43,8 @@ namespace OpenSim.Grid.MessagingServer { public class MessageService { - private LogBase m_log; + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private MessageServerConfig m_cfg; //A hashtable of all current presences this server knows about @@ -58,13 +59,10 @@ namespace OpenSim.Grid.MessagingServer // Hashtable containing work units that need to be processed private Hashtable m_unProcessedWorkUnits = new Hashtable(); - - public MessageService(LogBase log, MessageServerConfig cfg) + public MessageService(MessageServerConfig cfg) { - m_log = log; m_cfg = cfg; } - #region RegionComms Methods @@ -84,7 +82,7 @@ namespace OpenSim.Grid.MessagingServer ArrayList SendParams = new ArrayList(); SendParams.Add(PresenceParams); - MainLog.Instance.Verbose("PRESENCE", "Informing " + whichRegion.regionName + " at " + whichRegion.httpServerURI); + m_log.Info("[PRESENCE]: Informing " + whichRegion.regionName + " at " + whichRegion.httpServerURI); // Send XmlRpcRequest RegionReq = new XmlRpcRequest("presence_update", SendParams); XmlRpcResponse RegionResp = RegionReq.Send(whichRegion.httpServerURI, 6000); @@ -292,7 +290,7 @@ namespace OpenSim.Grid.MessagingServer } catch (WebException e) { - MainLog.Instance.Warn("Error when trying to fetch Avatar's friends list: " + + m_log.Warn("Error when trying to fetch Avatar's friends list: " + e.Message); // Return Empty list (no friends) } @@ -439,7 +437,7 @@ namespace OpenSim.Grid.MessagingServer if (responseData.ContainsKey("error")) { - m_log.Error("GRID","error received from grid server" + responseData["error"]); + m_log.Error("[GRID]: error received from grid server" + responseData["error"]); return null; } @@ -465,7 +463,7 @@ namespace OpenSim.Grid.MessagingServer } catch (WebException) { - MainLog.Instance.Error("GRID", + m_log.Error("[GRID]: " + "Region lookup failed for: " + regionHandle.ToString() + " - Is the GridServer down?"); return null; diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/Common.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Common.cs index 98a2cc5..bcfeefc 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Common.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/Common.cs @@ -26,10 +26,13 @@ * */ /* Original code: Tedd Hansen */ + namespace OpenSim.Grid.ScriptEngine.DotNetEngine { public static class Common { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + public static bool debug = true; public static ScriptEngine mySE; @@ -41,14 +44,14 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine public static void SendToDebug(string Message) { //if (Debug == true) - mySE.Log.Verbose("ScriptEngine", "Debug: " + Message); + mySE.m_log.Info("[ScriptEngine]: Debug: " + Message); //SendToDebugEvent("\r\n" + DateTime.Now.ToString("[HH:mm:ss] ") + Message); } public static void SendToLog(string Message) { //if (Debug == true) - mySE.Log.Verbose("ScriptEngine", "LOG: " + Message); + mySE.m_log.Info("[ScriptEngine]: LOG: " + Message); //SendToLogEvent("\r\n" + DateTime.Now.ToString("[HH:mm:ss] ") + Message); } } diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs index 1f5e6da..e0a5461 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs @@ -41,6 +41,8 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL //[Serializable] public class LSL_BaseClass : MarshalByRefObject, LSL_BuiltIn_Commands_Interface, IScript { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + // Object never expires public override Object InitializeLifetimeService() { @@ -87,7 +89,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL { m_LSL_Functions = LSL_Functions; - //MainLog.Instance.Notice("ScriptEngine", "LSL_BaseClass.Start() called."); + //m_log.Info("[ScriptEngine]: LSL_BaseClass.Start() called."); // Get this AppDomain's settings and display some of them. AppDomainSetup ads = AppDomain.CurrentDomain.SetupInformation; diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs index 8f58b55..1ffbd3a 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs @@ -52,6 +52,8 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler /// public class LSL_BuiltIn_Commands : MarshalByRefObject, LSL_BuiltIn_Commands_Interface { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private ASCIIEncoding enc = new ASCIIEncoding(); private ScriptEngine m_ScriptEngine; private SceneObjectPart m_host; @@ -68,7 +70,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler m_itemID = itemID; - //MainLog.Instance.Notice("ScriptEngine", "LSL_BaseClass.Start() called. Hosted by [" + m_host.Name + ":" + m_host.UUID + "@" + m_host.AbsolutePosition + "]"); + //m_log.Info("[ScriptEngine]: LSL_BaseClass.Start() called. Hosted by [" + m_host.Name + ":" + m_host.UUID + "@" + m_host.AbsolutePosition + "]"); } diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/EventManager.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/EventManager.cs index 3a1ae5a..3aa2216 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/EventManager.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/EventManager.cs @@ -38,17 +38,19 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine [Serializable] internal class EventManager { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private ScriptEngine myScriptEngine; //public IScriptHost TEMP_OBJECT_ID; public EventManager(ScriptEngine _ScriptEngine) { myScriptEngine = _ScriptEngine; // TODO: HOOK EVENTS UP TO SERVER! - //myScriptEngine.m_logger.Verbose("ScriptEngine", "EventManager Start"); + //myScriptEngine.m_log.Info("[ScriptEngine]: EventManager Start"); // TODO: ADD SERVER HOOK TO LOAD A SCRIPT THROUGH myScriptEngine.ScriptManager // Hook up a test event to our test form - myScriptEngine.Log.Verbose("ScriptEngine", "Hooking up to server events"); + myScriptEngine.m_log.Info("[ScriptEngine]: Hooking up to server events"); myScriptEngine.World.EventManager.OnObjectGrab += touch_start; myScriptEngine.World.EventManager.OnRezScript += OnRezScript; myScriptEngine.World.EventManager.OnRemoveScript += OnRemoveScript; @@ -57,7 +59,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine public void touch_start(uint localID, LLVector3 offsetPos, IClientAPI remoteClient) { // Add to queue for all scripts in ObjectID object - //myScriptEngine.m_logger.Verbose("ScriptEngine", "EventManager Event: touch_start"); + //myScriptEngine.m_log.Info("[ScriptEngine]: EventManager Event: touch_start"); //Console.WriteLine("touch_start localID: " + localID); myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_start", new object[] {(int) 1}); } diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/EventQueueManager.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/EventQueueManager.cs index d9d26aa..2606862 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/EventQueueManager.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/EventQueueManager.cs @@ -44,6 +44,8 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine [Serializable] internal class EventQueueManager { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + /// /// List of threads processing event queue /// @@ -118,7 +120,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine } catch (Exception) { - //myScriptEngine.Log.Verbose("ScriptEngine", "EventQueueManager Exception killing worker thread: " + e.ToString()); + //myScriptEngine.m_log.Info("[ScriptEngine]: EventQueueManager Exception killing worker thread: " + e.ToString()); } } } @@ -132,7 +134,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine /// private void EventQueueThreadLoop() { - //myScriptEngine.m_logger.Verbose("ScriptEngine", "EventQueueManager Worker thread spawned"); + //myScriptEngine.m_log.Info("[ScriptEngine]: EventQueueManager Worker thread spawned"); try { QueueItemStruct BlankQIS = new QueueItemStruct(); @@ -151,7 +153,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine else { // Something in queue, process - //myScriptEngine.m_logger.Verbose("ScriptEngine", "Processing event for localID: " + QIS.localID + ", itemID: " + QIS.itemID + ", FunctionName: " + QIS.FunctionName); + //myScriptEngine.m_log.Info("[ScriptEngine]: Processing event for localID: " + QIS.localID + ", itemID: " + QIS.itemID + ", FunctionName: " + QIS.FunctionName); // OBJECT BASED LOCK - TWO THREADS WORKING ON SAME OBJECT IS NOT GOOD lock (queueLock) @@ -237,7 +239,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine } // try catch (ThreadAbortException) { - //myScriptEngine.Log.Verbose("ScriptEngine", "EventQueueManager Worker thread killed: " + tae.Message); + //myScriptEngine.m_log.Info("[ScriptEngine]: EventQueueManager Worker thread killed: " + tae.Message); } } @@ -287,7 +289,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine public void AddToObjectQueue(uint localID, string FunctionName, object[] param) { // Determine all scripts in Object and add to their queue - //myScriptEngine.m_logger.Verbose("ScriptEngine", "EventQueueManager Adding localID: " + localID + ", FunctionName: " + FunctionName); + //myScriptEngine.m_log.Info("[ScriptEngine]: EventQueueManager Adding localID: " + localID + ", FunctionName: " + FunctionName); // Do we have any scripts in this object at all? If not, return diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/ScriptEngine.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/ScriptEngine.cs index cc6cde2..a45efe9 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/ScriptEngine.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/ScriptEngine.cs @@ -40,6 +40,8 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine [Serializable] public class ScriptEngine : IRegionModule { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + internal Scene World; internal EventManager m_EventManager; // Handles and queues incoming events from OpenSim internal EventQueueManager m_EventQueueManager; // Executes events @@ -47,7 +49,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine internal AppDomainManager m_AppDomainManager; internal LSLLongCmdHandler m_LSLLongCmdHandler; - private LogBase m_log; public ScriptEngine() { @@ -55,19 +56,13 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine Common.mySE = this; } - public LogBase Log - { - get { return m_log; } - } - - public void InitializeEngine(Scene Sceneworld, LogBase logger) + public void InitializeEngine(Scene Sceneworld) { World = Sceneworld; - m_log = logger; - Log.Verbose("ScriptEngine", "DotNet & LSL ScriptEngine initializing"); + m_log.Info("[ScriptEngine]: DotNet & LSL ScriptEngine initializing"); - //m_logger.Status("ScriptEngine", "InitializeEngine"); + //m_log.Info("[ScriptEngine]: InitializeEngine"); // Create all objects we'll be using m_EventQueueManager = new EventQueueManager(this); @@ -90,7 +85,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine //public void StartScript(string ScriptID, IScriptHost ObjectID) //{ // this.myEventManager.TEMP_OBJECT_ID = ObjectID; - // Log.Status("ScriptEngine", "DEBUG FUNCTION: StartScript: " + ScriptID); + // m_log.Info("[ScriptEngine]: DEBUG FUNCTION: StartScript: " + ScriptID); // myScriptManager.StartScript(ScriptID, ObjectID); //} @@ -98,7 +93,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine public void Initialise(Scene scene, IConfigSource config) { - InitializeEngine(scene, MainLog.Instance); + InitializeEngine(scene); } public void PostInitialise() diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/ScriptManager.cs index f482834..2846399 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/ScriptManager.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/ScriptManager.cs @@ -48,6 +48,8 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine [Serializable] public class ScriptManager { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + #region Declares private Thread scriptLoadUnloadThread; @@ -312,7 +314,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine } catch (Exception e) { - //m_scriptEngine.Log.Error("ScriptEngine", "Error compiling script: " + e.ToString()); + //m_scriptEngine.m_log.Error("[ScriptEngine]: Error compiling script: " + e.ToString()); try { // DISPLAY ERROR INWORLD @@ -323,7 +325,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine } catch (Exception e2) { - m_scriptEngine.Log.Error("ScriptEngine", "Error displaying error in-world: " + e2.ToString()); + m_scriptEngine.m_log.Error("[ScriptEngine]: Error displaying error in-world: " + e2.ToString()); } } } @@ -384,7 +386,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine internal void ExecuteEvent(uint localID, LLUUID itemID, string FunctionName, object[] args) { // Execute a function in the script - //m_scriptEngine.Log.Verbose("ScriptEngine", "Executing Function localID: " + localID + ", itemID: " + itemID + ", FunctionName: " + FunctionName); + //m_scriptEngine.m_log.Info("[ScriptEngine]: Executing Function localID: " + localID + ", itemID: " + itemID + ", FunctionName: " + FunctionName); LSL_BaseClass Script = m_scriptEngine.m_ScriptManager.GetScript(localID, itemID); if (Script == null) return; diff --git a/OpenSim/Grid/ScriptServer/Application.cs b/OpenSim/Grid/ScriptServer/Application.cs index 5857101..26bd426 100644 --- a/OpenSim/Grid/ScriptServer/Application.cs +++ b/OpenSim/Grid/ScriptServer/Application.cs @@ -37,6 +37,8 @@ namespace OpenSim.Grid.ScriptServer private static void Main(string[] args) { + log4net.Config.XmlConfigurator.Configure(); + AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); diff --git a/OpenSim/Grid/ScriptServer/ScriptServer/Region/RegionConnectionManager.cs b/OpenSim/Grid/ScriptServer/ScriptServer/Region/RegionConnectionManager.cs index 819a037..595acea 100644 --- a/OpenSim/Grid/ScriptServer/ScriptServer/Region/RegionConnectionManager.cs +++ b/OpenSim/Grid/ScriptServer/ScriptServer/Region/RegionConnectionManager.cs @@ -33,14 +33,12 @@ namespace OpenSim.Grid.ScriptServer // Maintains connection and communication to a region public class RegionConnectionManager : RegionBase { - private LogBase m_log; private ScriptServerMain m_ScriptServerMain; private object m_Connection; - public RegionConnectionManager(ScriptServerMain scm, LogBase logger, object Connection) + public RegionConnectionManager(ScriptServerMain scm, object Connection) { m_ScriptServerMain = scm; - m_log = logger; m_Connection = Connection; } diff --git a/OpenSim/Grid/ScriptServer/ScriptServer/RegionCommManager.cs b/OpenSim/Grid/ScriptServer/ScriptServer/RegionCommManager.cs index 7d29129..524b8c4 100644 --- a/OpenSim/Grid/ScriptServer/ScriptServer/RegionCommManager.cs +++ b/OpenSim/Grid/ScriptServer/ScriptServer/RegionCommManager.cs @@ -38,13 +38,11 @@ namespace OpenSim.Grid.ScriptServer private List Regions = new List(); - private LogBase m_log; private ScriptServerMain m_ScriptServerMain; - public RegionCommManager(ScriptServerMain scm, LogBase logger) + public RegionCommManager(ScriptServerMain scm) { m_ScriptServerMain = scm; - m_log = logger; } ~RegionCommManager() @@ -96,9 +94,8 @@ namespace OpenSim.Grid.ScriptServer // ~ ask scriptengines if they will accept script? // - Add script to shared communication channel towards that region - // TODO: FAKING A CONNECTION - Regions.Add(new RegionConnectionManager(m_ScriptServerMain, m_log, null)); + Regions.Add(new RegionConnectionManager(m_ScriptServerMain, null)); } } } \ No newline at end of file diff --git a/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEngineLoader.cs b/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEngineLoader.cs index c9c0fb0..4bb74f5 100644 --- a/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEngineLoader.cs +++ b/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEngineLoader.cs @@ -35,13 +35,7 @@ namespace OpenSim.Grid.ScriptServer.ScriptServer { internal class ScriptEngineLoader { - private LogBase m_log; - - - public ScriptEngineLoader(LogBase logger) - { - m_log = logger; - } + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); public ScriptServerInterfaces.ScriptEngine LoadScriptEngine(string EngineName) { @@ -55,7 +49,7 @@ namespace OpenSim.Grid.ScriptServer.ScriptServer } catch (Exception e) { - m_log.Error("ScriptEngine", + m_log.Error("[ScriptEngine]: " + "Error loading assembly \"" + EngineName + "\": " + e.Message + ", " + e.StackTrace.ToString()); } @@ -87,7 +81,7 @@ namespace OpenSim.Grid.ScriptServer.ScriptServer //} //catch (Exception e) //{ - // m_log.Error("ScriptEngine", "Error loading assembly \String.Empty + FileName + "\": " + e.ToString()); + // m_log.Error("[ScriptEngine]: Error loading assembly \String.Empty + FileName + "\": " + e.ToString()); //} @@ -104,7 +98,7 @@ namespace OpenSim.Grid.ScriptServer.ScriptServer //} //catch (Exception e) //{ - // m_log.Error("ScriptEngine", "Error initializing type \String.Empty + NameSpace + "\" from \String.Empty + FileName + "\": " + e.ToString()); + // m_log.Error("[ScriptEngine]: Error initializing type \String.Empty + NameSpace + "\" from \String.Empty + FileName + "\": " + e.ToString()); //} ScriptServerInterfaces.ScriptEngine ret; @@ -114,7 +108,7 @@ namespace OpenSim.Grid.ScriptServer.ScriptServer //} //catch (Exception e) //{ - // m_log.Error("ScriptEngine", "Error initializing type \String.Empty + NameSpace + "\" from \String.Empty + FileName + "\": " + e.ToString()); + // m_log.Error("[ScriptEngine]: Error initializing type \String.Empty + NameSpace + "\" from \String.Empty + FileName + "\": " + e.ToString()); //} return ret; diff --git a/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEnginesManager.cs b/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEnginesManager.cs index 3bfca87..7976cb5 100644 --- a/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEnginesManager.cs +++ b/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEnginesManager.cs @@ -34,17 +34,15 @@ namespace OpenSim.Grid.ScriptServer.ScriptServer { internal class ScriptEngineManager { - private LogBase m_log; private ScriptEngineLoader ScriptEngineLoader; private List scriptEngines = new List(); private ScriptServerMain m_ScriptServerMain; // Initialize - public ScriptEngineManager(ScriptServerMain scm, LogBase logger) + public ScriptEngineManager(ScriptServerMain scm) { m_ScriptServerMain = scm; - m_log = logger; - ScriptEngineLoader = new ScriptEngineLoader(m_log); + ScriptEngineLoader = new ScriptEngineLoader(); } ~ScriptEngineManager() diff --git a/OpenSim/Grid/ScriptServer/ScriptServerMain.cs b/OpenSim/Grid/ScriptServer/ScriptServerMain.cs index 421467d..e2c83f1 100644 --- a/OpenSim/Grid/ScriptServer/ScriptServerMain.cs +++ b/OpenSim/Grid/ScriptServer/ScriptServerMain.cs @@ -40,11 +40,12 @@ namespace OpenSim.Grid.ScriptServer { public class ScriptServerMain : BaseOpenSimServer, conscmd_callback { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + // // Root object. Creates objects used. // private int listenPort = 8010; - private readonly string m_logFilename = ("scriptserver.log"); // TEMP public static ScriptServerInterfaces.ScriptEngine Engine; @@ -59,16 +60,15 @@ namespace OpenSim.Grid.ScriptServer public ScriptServerMain() { - m_log = CreateLog(); - + m_console = CreateConsole(); // Set up script engine mananger - ScriptEngines = new ScriptEngineManager(this, m_log); + ScriptEngines = new ScriptEngineManager(this); // Load DotNetEngine Engine = ScriptEngines.LoadEngine("DotNetEngine"); IConfigSource config = null; - Engine.InitializeEngine(null, null, m_log, false, Engine.GetScriptManager()); + Engine.InitializeEngine(null, null, false, Engine.GetScriptManager()); // Set up server @@ -83,12 +83,12 @@ namespace OpenSim.Grid.ScriptServer private void RPC_ReceiveCommand(int ID, string Command, object[] p) { - m_log.Notice("SERVER", "Received command: '" + Command + "'"); + m_log.Info("[SERVER]: Received command: '" + Command + "'"); if (p != null) { for (int i = 0; i < p.Length; i++) { - m_log.Notice("SERVER", "Param " + i + ": " + p[i].ToString()); + m_log.Info("[SERVER]: Param " + i + ": " + p[i].ToString()); } } @@ -102,14 +102,9 @@ namespace OpenSim.Grid.ScriptServer { } - protected LogBase CreateLog() + protected ConsoleBase CreateConsole() { - if (!Directory.Exists(Util.logDir())) - { - Directory.CreateDirectory(Util.logDir()); - } - - return new LogBase((Path.Combine(Util.logDir(), m_logFilename)), "ScriptServer", this, true); + return new ConsoleBase("ScriptServer", this); } } } diff --git a/OpenSim/Grid/UserServer.Config/DbUserConfig.cs b/OpenSim/Grid/UserServer.Config/DbUserConfig.cs index d2736c6..865dfea 100644 --- a/OpenSim/Grid/UserServer.Config/DbUserConfig.cs +++ b/OpenSim/Grid/UserServer.Config/DbUserConfig.cs @@ -35,9 +35,11 @@ namespace OpenUser.Config.UserConfigDb4o { public class Db4oConfigPlugin: IUserConfig { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + public UserConfig GetConfigObject() { - MainLog.Instance.Verbose("DBUSERCONFIG", "Loading Db40Config dll"); + m_log.Info("[DBUSERCONFIG]: Loading Db40Config dll"); return ( new DbUserConfig()); } } @@ -48,13 +50,13 @@ namespace OpenUser.Config.UserConfigDb4o public void LoadDefaults() { - MainLog.Instance.Notice("DbUserConfig.cs:LoadDefaults() - Please press enter to retain default or enter new settings"); + m_log.Info("DbUserConfig.cs:LoadDefaults() - Please press enter to retain default or enter new settings"); - this.DefaultStartupMsg = MainLog.Instance.CmdPrompt("Default startup message", "Welcome to OGS"); + this.DefaultStartupMsg = m_log.CmdPrompt("Default startup message", "Welcome to OGS"); - this.GridServerURL = MainLog.Instance.CmdPrompt("Grid server URL","http://127.0.0.1:" + GridConfig.DefaultHttpPort.ToString() + "/"); - this.GridSendKey = MainLog.Instance.CmdPrompt("Key to send to grid server","null"); - this.GridRecvKey = MainLog.Instance.CmdPrompt("Key to expect from grid server","null"); + this.GridServerURL = m_log.CmdPrompt("Grid server URL","http://127.0.0.1:" + GridConfig.DefaultHttpPort.ToString() + "/"); + this.GridSendKey = m_log.CmdPrompt("Key to send to grid server","null"); + this.GridRecvKey = m_log.CmdPrompt("Key to expect from grid server","null"); } public override void InitConfig() @@ -65,7 +67,7 @@ namespace OpenUser.Config.UserConfigDb4o IObjectSet result = db.Get(typeof(DbUserConfig)); if(result.Count==1) { - MainLog.Instance.Verbose("DBUSERCONFIG", "DbUserConfig.cs:InitConfig() - Found a UserConfig object in the local database, loading"); + m_log.Info("[DBUSERCONFIG]: DbUserConfig.cs:InitConfig() - Found a UserConfig object in the local database, loading"); foreach (DbUserConfig cfg in result) { this.GridServerURL=cfg.GridServerURL; @@ -76,24 +78,24 @@ namespace OpenUser.Config.UserConfigDb4o } else { - MainLog.Instance.Verbose("DBUSERCONFIG", "DbUserConfig.cs:InitConfig() - Could not find object in database, loading precompiled defaults"); + m_log.Info("[DBUSERCONFIG]: DbUserConfig.cs:InitConfig() - Could not find object in database, loading precompiled defaults"); LoadDefaults(); - MainLog.Instance.Verbose("DBUSERCONFIG", "Writing out default settings to local database"); + m_log.Info("[DBUSERCONFIG]: Writing out default settings to local database"); db.Set(this); db.Close(); } } catch(Exception e) { - MainLog.Instance.Warn("DbUserConfig.cs:InitConfig() - Exception occured"); - MainLog.Instance.Warn(e.ToString()); + m_log.Warn("DbUserConfig.cs:InitConfig() - Exception occured"); + m_log.Warn(e.ToString()); } - MainLog.Instance.Verbose("DBUSERCONFIG", "User settings loaded:"); - MainLog.Instance.Verbose("DBUSERCONFIG", "Default startup message: " + this.DefaultStartupMsg); - MainLog.Instance.Verbose("DBUSERCONFIG", "Grid server URL: " + this.GridServerURL); - MainLog.Instance.Verbose("DBUSERCONFIG", "Key to send to grid: " + this.GridSendKey); - MainLog.Instance.Verbose("DBUSERCONFIG", "Key to expect from grid: " + this.GridRecvKey); + m_log.Info("[DBUSERCONFIG]: User settings loaded:"); + m_log.Info("[DBUSERCONFIG]: Default startup message: " + this.DefaultStartupMsg); + m_log.Info("[DBUSERCONFIG]: Grid server URL: " + this.GridServerURL); + m_log.Info("[DBUSERCONFIG]: Key to send to grid: " + this.GridSendKey); + m_log.Info("[DBUSERCONFIG]: Key to expect from grid: " + this.GridRecvKey); } public void Shutdown() diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs index 32cefc1..8b9fd62 100644 --- a/OpenSim/Grid/UserServer/Main.cs +++ b/OpenSim/Grid/UserServer/Main.cs @@ -42,6 +42,8 @@ namespace OpenSim.Grid.UserServer /// public class OpenUser_Main : BaseOpenSimServer, conscmd_callback { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private UserConfig Cfg; public UserManager m_userManager; @@ -53,7 +55,9 @@ namespace OpenSim.Grid.UserServer [STAThread] public static void Main(string[] args) { - Console.WriteLine("Launching UserServer..."); + log4net.Config.XmlConfigurator.Configure(); + + m_log.Info("Launching UserServer..."); OpenUser_Main userserver = new OpenUser_Main(); @@ -63,22 +67,17 @@ namespace OpenSim.Grid.UserServer private OpenUser_Main() { - if (!Directory.Exists(Util.logDir())) - { - Directory.CreateDirectory(Util.logDir()); - } - m_log = - new LogBase((Path.Combine(Util.logDir(), "opengrid-userserver-console.log")), "OpenUser", this, true); - MainLog.Instance = m_log; + m_console = new ConsoleBase("OpenUser", this); + MainConsole.Instance = m_console; } private void Work() { - m_log.Notice("Enter help for a list of commands\n"); + m_console.Notice("Enter help for a list of commands\n"); while (true) { - m_log.MainLogPrompt(); + m_console.Prompt(); } } @@ -88,7 +87,7 @@ namespace OpenSim.Grid.UserServer StatsManager.StartCollectingUserStats(); - MainLog.Instance.Verbose("REGION", "Establishing data connection"); + m_log.Info("[REGION]: Establishing data connection"); m_userManager = new UserManager(); m_userManager._config = Cfg; m_userManager.AddPlugin(Cfg.DatabaseProvider); @@ -96,11 +95,11 @@ namespace OpenSim.Grid.UserServer m_loginService = new UserLoginService( m_userManager, new LibraryRootFolder(), Cfg, Cfg.DefaultStartupMsg); - m_messagesService = new MessageServersConnector(MainLog.Instance); + m_messagesService = new MessageServersConnector(); m_loginService.OnUserLoggedInAtLocation += NotifyMessageServersUserLoggedInToLocation; - MainLog.Instance.Verbose("REGION", "Starting HTTP process"); + m_log.Info("[REGION]: Starting HTTP process"); BaseHttpServer httpServer = new BaseHttpServer(Cfg.HttpPort); httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod); @@ -128,10 +127,9 @@ namespace OpenSim.Grid.UserServer new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod)); httpServer.Start(); - m_log.Status("SERVER", "Userserver 0.4 - Startup complete"); + m_log.Info("[SERVER]: Userserver 0.4 - Startup complete"); } - public void do_create(string what) { switch (what) @@ -143,11 +141,11 @@ namespace OpenSim.Grid.UserServer uint regX = 1000; uint regY = 1000; - tempfirstname = m_log.CmdPrompt("First name"); - templastname = m_log.CmdPrompt("Last name"); - tempMD5Passwd = m_log.PasswdPrompt("Password"); - regX = Convert.ToUInt32(m_log.CmdPrompt("Start Region X")); - regY = Convert.ToUInt32(m_log.CmdPrompt("Start Region Y")); + tempfirstname = m_console.CmdPrompt("First name"); + templastname = m_console.CmdPrompt("Last name"); + tempMD5Passwd = m_console.PasswdPrompt("Password"); + regX = Convert.ToUInt32(m_console.CmdPrompt("Start Region X")); + regY = Convert.ToUInt32(m_console.CmdPrompt("Start Region Y")); tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + String.Empty); @@ -158,7 +156,7 @@ namespace OpenSim.Grid.UserServer m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY); } catch (Exception ex) { - m_log.Error("SERVER", "Error creating user: {0}", ex.ToString()); + m_log.Error(String.Format("[SERVER]: Error creating user: {0}", ex.ToString())); } try @@ -168,7 +166,7 @@ namespace OpenSim.Grid.UserServer } catch (Exception ex) { - m_log.Error("SERVER", "Error creating inventory for user: {0}", ex.ToString()); + m_log.Error(String.Format("[SERVER]: Error creating inventory for user: {0}", ex.ToString())); } m_lastCreatedUser = userID; break; @@ -182,9 +180,9 @@ namespace OpenSim.Grid.UserServer switch (cmd) { case "help": - m_log.Notice("create user - create a new user"); - m_log.Notice("stats - statistical information for this server"); - m_log.Notice("shutdown - shutdown the grid (USE CAUTION!)"); + m_console.Notice("create user - create a new user"); + m_console.Notice("stats - statistical information for this server"); + m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)"); break; case "create": @@ -193,12 +191,12 @@ namespace OpenSim.Grid.UserServer case "shutdown": m_loginService.OnUserLoggedInAtLocation -= NotifyMessageServersUserLoggedInToLocation; - m_log.Close(); + m_console.Close(); Environment.Exit(0); break; case "stats": - MainLog.Instance.Notice("STATS", Environment.NewLine + StatsManager.UserStats.Report()); + m_console.Notice(StatsManager.UserStats.Report()); break; case "test-inventory": @@ -218,8 +216,9 @@ namespace OpenSim.Grid.UserServer public void TestResponse(List resp) { - Console.WriteLine("response got"); + m_console.Notice("response got"); } + public void NotifyMessageServersUserLoggedInToLocation(LLUUID agentID, LLUUID sessionID, LLUUID RegionID, ulong regionhandle, LLVector3 Position) { m_messagesService.TellMessageServersAboutUser(agentID, sessionID, RegionID, regionhandle, Position); diff --git a/OpenSim/Grid/UserServer/MessageServersConnector.cs b/OpenSim/Grid/UserServer/MessageServersConnector.cs index 93d5925..251644b 100644 --- a/OpenSim/Grid/UserServer/MessageServersConnector.cs +++ b/OpenSim/Grid/UserServer/MessageServersConnector.cs @@ -39,15 +39,14 @@ using OpenSim.Framework.Servers; namespace OpenSim.Grid.UserServer { - public class MessageServersConnector { - private LogBase m_log; + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + public Dictionary MessageServers; - public MessageServersConnector(LogBase log) + public MessageServersConnector() { - m_log=log; MessageServers = new Dictionary(); } @@ -65,7 +64,7 @@ namespace OpenSim.Grid.UserServer { if (!MessageServers.ContainsKey(URI)) { - m_log.Warn("MSGSERVER", "Got addResponsibleRegion Request for a MessageServer that isn't registered"); + m_log.Warn("[MSGSERVER]: Got addResponsibleRegion Request for a MessageServer that isn't registered"); } else { @@ -78,7 +77,7 @@ namespace OpenSim.Grid.UserServer { if (!MessageServers.ContainsKey(URI)) { - m_log.Warn("MSGSERVER", "Got RemoveResponsibleRegion Request for a MessageServer that isn't registered"); + m_log.Warn("[MSGSERVER]: Got RemoveResponsibleRegion Request for a MessageServer that isn't registered"); } else { @@ -175,10 +174,7 @@ namespace OpenSim.Grid.UserServer XmlRpcRequest GridReq = new XmlRpcRequest("login_to_simulator", SendParams); XmlRpcResponse GridResp = GridReq.Send(serv.URI, 6000); - m_log.Verbose("LOGIN","Notified : " + serv.URI + " about user login"); - + m_log.Info("[LOGIN]: Notified : " + serv.URI + " about user login"); } - - } } diff --git a/OpenSim/Grid/UserServer/UserLoginService.cs b/OpenSim/Grid/UserServer/UserLoginService.cs index 10f9468..d5cdf1c 100644 --- a/OpenSim/Grid/UserServer/UserLoginService.cs +++ b/OpenSim/Grid/UserServer/UserLoginService.cs @@ -46,9 +46,10 @@ namespace OpenSim.Grid.UserServer { public delegate void UserLoggedInAtLocation(LLUUID agentID, LLUUID sessionID, LLUUID RegionID, ulong regionhandle, LLVector3 Position); - public class UserLoginService : LoginService { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + public event UserLoggedInAtLocation OnUserLoggedInAtLocation; public UserConfig m_config; @@ -70,7 +71,7 @@ namespace OpenSim.Grid.UserServer { bool tryDefault = false; //CFK: Since the try is always "tried", the "Home Location" message should always appear, so comment this one. - //CFK: MainLog.Instance.Verbose("LOGIN", "Load information from the gridserver"); + //CFK: m_log.Info("[LOGIN]: Load information from the gridserver"); RegionProfileData SimInfo = new RegionProfileData(); try { @@ -80,7 +81,7 @@ namespace OpenSim.Grid.UserServer // Customise the response //CFK: This is redundant and the next message should always appear. - //CFK: MainLog.Instance.Verbose("LOGIN", "Home Location"); + //CFK: m_log.Info("[LOGIN]: Home Location"); response.Home = "{'region_handle':[r" + (SimInfo.regionLocX*256).ToString() + ",r" + (SimInfo.regionLocY*256).ToString() + "], " + "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + @@ -91,7 +92,7 @@ namespace OpenSim.Grid.UserServer // Destination //CFK: The "Notifying" message always seems to appear, so subsume the data from this message into //CFK: the next one for X & Y and comment this one. - //CFK: MainLog.Instance.Verbose("LOGIN", "CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + + //CFK: m_log.Info("[LOGIN]: CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + //CFK: "; Region Y: " + SimInfo.regionLocY); response.SimAddress = Util.GetHostFromDNS(SimInfo.serverIP).ToString(); response.SimPort = (uint) SimInfo.serverPort; @@ -105,7 +106,7 @@ namespace OpenSim.Grid.UserServer // Notify the target of an incoming user //CFK: The "Notifying" message always seems to appear, so subsume the data from this message into //CFK: the next one for X & Y and comment this one. - //CFK: MainLog.Instance.Verbose("LOGIN", SimInfo.regionName + " (" + SimInfo.serverURI + ") " + + //CFK: m_log.Info("[LOGIN]: " + SimInfo.regionName + " (" + SimInfo.serverURI + ") " + //CFK: SimInfo.regionLocX + "," + SimInfo.regionLocY); // Prepare notification @@ -128,7 +129,7 @@ namespace OpenSim.Grid.UserServer theUser.currentAgent.currentRegion = SimInfo.UUID; theUser.currentAgent.currentHandle = SimInfo.regionHandle; - MainLog.Instance.Verbose("LOGIN", SimInfo.regionName + " @ " + SimInfo.httpServerURI + " " + + m_log.Info("[LOGIN]: " + SimInfo.regionName + " @ " + SimInfo.httpServerURI + " " + SimInfo.regionLocX + "," + SimInfo.regionLocY); XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams); @@ -145,9 +146,8 @@ namespace OpenSim.Grid.UserServer ulong defaultHandle = (((ulong) m_config.DefaultX*256) << 32) | ((ulong) m_config.DefaultY*256); - MainLog.Instance.Warn( - "LOGIN", - "Home region not available: sending to default " + defaultHandle.ToString()); + m_log.Warn( + "[LOGIN]: Home region not available: sending to default " + defaultHandle.ToString()); SimInfo = new RegionProfileData(); try @@ -157,7 +157,7 @@ namespace OpenSim.Grid.UserServer m_config.GridSendKey, m_config.GridRecvKey); // Customise the response - MainLog.Instance.Verbose("LOGIN", "Home Location"); + m_log.Info("[LOGIN]: Home Location"); response.Home = "{'region_handle':[r" + (SimInfo.regionLocX*256).ToString() + ",r" + (SimInfo.regionLocY*256).ToString() + "], " + "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + @@ -166,9 +166,9 @@ namespace OpenSim.Grid.UserServer theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}"; // Destination - MainLog.Instance.Verbose("LOGIN", - "CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " + - SimInfo.regionLocY); + m_log.Info("[LOGIN]: " + + "CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " + + SimInfo.regionLocY); response.SimAddress = Util.GetHostFromDNS(SimInfo.serverIP).ToString(); response.SimPort = (uint) SimInfo.serverPort; response.RegionX = SimInfo.regionLocX; @@ -179,7 +179,7 @@ namespace OpenSim.Grid.UserServer response.SeedCapability = SimInfo.httpServerURI + "CAPS/" + capsPath + "0000/"; // Notify the target of an incoming user - MainLog.Instance.Verbose("LOGIN", "Notifying " + SimInfo.regionName + " (" + SimInfo.serverURI + ")"); + m_log.Info("[LOGIN]: Notifying " + SimInfo.regionName + " (" + SimInfo.serverURI + ")"); // Update agent with target sim theUser.currentAgent.currentRegion = SimInfo.UUID; @@ -201,7 +201,7 @@ namespace OpenSim.Grid.UserServer ArrayList SendParams = new ArrayList(); SendParams.Add(SimParams); - MainLog.Instance.Verbose("LOGIN", "Informing region at " + SimInfo.httpServerURI); + m_log.Info("[LOGIN]: Informing region at " + SimInfo.httpServerURI); // Send XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams); XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000); @@ -213,8 +213,8 @@ namespace OpenSim.Grid.UserServer catch (Exception e) { - MainLog.Instance.Warn("LOGIN", "Default region also not available"); - MainLog.Instance.Warn("LOGIN", e.ToString()); + m_log.Warn("[LOGIN]: Default region also not available"); + m_log.Warn("[LOGIN]: " + e.ToString()); } } } @@ -230,8 +230,8 @@ namespace OpenSim.Grid.UserServer // which does. if (null == folders | folders.Count == 0) { - MainLog.Instance.Warn( - "LOGIN", + m_log.Warn( + "[LOGIN]: " + "A root inventory folder for user ID " + userID + " was not found. A new set" + " of empty inventory folders is being created."); @@ -269,8 +269,8 @@ namespace OpenSim.Grid.UserServer } else { - MainLog.Instance.Warn("LOGIN", "The root inventory folder could still not be retrieved" + - " for user ID " + userID); + m_log.Warn("[LOGIN]: The root inventory folder could still not be retrieved" + + " for user ID " + userID); AgentInventory userInventory = new AgentInventory(); userInventory.CreateRootFolder(userID, false); diff --git a/OpenSim/Grid/UserServer/UserManager.cs b/OpenSim/Grid/UserServer/UserManager.cs index c36de7f..8f2d83c 100644 --- a/OpenSim/Grid/UserServer/UserManager.cs +++ b/OpenSim/Grid/UserServer/UserManager.cs @@ -39,6 +39,8 @@ namespace OpenSim.Grid.UserServer { public class UserManager : UserManagerBase { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + /// /// Deletes an active agent session /// @@ -106,6 +108,7 @@ namespace OpenSim.Grid.UserServer return response; } + /// /// Converts a user profile to an XML element which can be returned /// @@ -202,7 +205,6 @@ namespace OpenSim.Grid.UserServer responseData["returnString"] = returnString; response.Value = responseData; return response; - } public XmlRpcResponse XmlRpcResponseXmlRPCUpdateUserFriendPerms(XmlRpcRequest request) @@ -212,8 +214,6 @@ namespace OpenSim.Grid.UserServer Hashtable responseData = new Hashtable(); string returnString = "FALSE"; - - if (requestData.Contains("ownerID") && requestData.Contains("friendID") && requestData.Contains("friendPerms")) { UpdateUserFriendPerms(new LLUUID((string)requestData["ownerID"]), new LLUUID((string)requestData["friendID"]), (uint)Convert.ToInt32((string)requestData["friendPerms"])); @@ -233,8 +233,6 @@ namespace OpenSim.Grid.UserServer List returndata = new List(); - - if (requestData.Contains("ownerID")) { returndata = this.GetUserFriendList(new LLUUID((string)requestData["ownerID"])); @@ -309,7 +307,6 @@ namespace OpenSim.Grid.UserServer return CreateUnknownUserErrorResponse(); } - return ProfileToXmlRPCResponse(userProfile); } @@ -318,7 +315,6 @@ namespace OpenSim.Grid.UserServer XmlRpcResponse response = new XmlRpcResponse(); Hashtable requestData = (Hashtable)request.Params[0]; - UserProfileData userProfile; if (requestData.Contains("avatar_uuid")) @@ -336,17 +332,15 @@ namespace OpenSim.Grid.UserServer } catch (FormatException) { - OpenSim.Framework.Console.MainLog.Instance.Warn("LOGOUT", "Error in Logout XMLRPC Params"); + m_log.Warn("[LOGOUT]: Error in Logout XMLRPC Params"); return response; } - } else { return CreateUnknownUserErrorResponse(); } - return response; } -- cgit v1.1