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. --- .../Grid/InventoryServer/GridInventoryService.cs | 24 ++++++++++++---------- OpenSim/Grid/InventoryServer/InventoryManager.cs | 16 ++++++++------- OpenSim/Grid/InventoryServer/Main.cs | 22 ++++++++++++-------- 3 files changed, 35 insertions(+), 27 deletions(-) (limited to 'OpenSim/Grid/InventoryServer') 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; } -- cgit v1.1