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. --- .../Framework/Communications/Cache/AssetCache.cs | 21 ++++++------ .../Framework/Communications/Cache/AssetServer.cs | 8 +++-- .../Communications/Cache/AssetServerBase.cs | 18 +++++----- .../Communications/Cache/GridAssetClient.cs | 18 +++++----- .../Communications/Cache/LibraryRootFolder.cs | 38 ++++++++++++---------- .../Communications/Cache/SQLAssetServer.cs | 13 ++++---- .../Cache/UserProfileCacheService.cs | 26 ++++++++------- 7 files changed, 77 insertions(+), 65 deletions(-) (limited to 'OpenSim/Framework/Communications/Cache') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index db2d2fe..84713b9 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -44,6 +44,8 @@ namespace OpenSim.Framework.Communications.Cache /// public class AssetCache : IAssetReceiver { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + public Dictionary Assets; public Dictionary Textures; @@ -61,14 +63,13 @@ namespace OpenSim.Framework.Communications.Cache private readonly IAssetServer m_assetServer; private readonly Thread m_assetCacheThread; - private readonly LogBase m_log; /// /// /// - public AssetCache(IAssetServer assetServer, LogBase log) + public AssetCache(IAssetServer assetServer) { - log.Verbose("ASSETSTORAGE", "Creating Asset cache"); + m_log.Info("[ASSETSTORAGE]: Creating Asset cache"); m_assetServer = assetServer; m_assetServer.SetReceiver(this); Assets = new Dictionary(); @@ -76,8 +77,6 @@ namespace OpenSim.Framework.Communications.Cache m_assetCacheThread = new Thread(new ThreadStart(RunAssetManager)); m_assetCacheThread.IsBackground = true; m_assetCacheThread.Start(); - - m_log = log; } /// @@ -94,7 +93,7 @@ namespace OpenSim.Framework.Communications.Cache } catch (Exception e) { - m_log.Error("ASSETCACHE", e.ToString()); + m_log.Error("[ASSETCACHE]: " + e.ToString()); } } } @@ -198,8 +197,8 @@ namespace OpenSim.Framework.Communications.Cache } } while (--maxPolls > 0); - MainLog.Instance.Warn( - "ASSETCACHE", "Asset {0} was not received before the retrieval timeout was reached"); + m_log.Warn( + String.Format("[ASSETCACHE]: Asset {0} was not received before the retrieval timeout was reached")); return null; } @@ -266,7 +265,7 @@ namespace OpenSim.Framework.Communications.Cache } } - m_log.Verbose("ASSETCACHE", "Adding {0} {1} [{2}]: {3}.", temporary, type, asset.FullID, result); + m_log.Info(String.Format("[ASSETCACHE]: Adding {0} {1} [{2}]: {3}.", temporary, type, asset.FullID, result)); } public void DeleteAsset(LLUUID assetID) @@ -362,7 +361,7 @@ namespace OpenSim.Framework.Communications.Cache { //if (this.RequestedTextures.ContainsKey(assetID)) //{ - // MainLog.Instance.Warn("ASSET CACHE", "sending image not found for {0}", assetID); + // m_log.Warn(String.Format("[ASSET CACHE]: sending image not found for {0}", assetID)); // AssetRequest req = this.RequestedTextures[assetID]; // ImageNotInDatabasePacket notFound = new ImageNotInDatabasePacket(); // notFound.ImageID.ID = assetID; @@ -371,7 +370,7 @@ namespace OpenSim.Framework.Communications.Cache //} //else //{ - // MainLog.Instance.Error("ASSET CACHE", "Cound not send image not found for {0}", assetID); + // m_log.Error(String.Format("[ASSET CACHE]: Cound not send image not found for {0}", assetID)); //} } diff --git a/OpenSim/Framework/Communications/Cache/AssetServer.cs b/OpenSim/Framework/Communications/Cache/AssetServer.cs index 575e80a..c1cf100 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServer.cs @@ -35,6 +35,8 @@ namespace OpenSim.Framework.Communications.Cache { public class LocalAssetServer : AssetServerBase { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private IObjectContainer db; public LocalAssetServer() @@ -43,7 +45,7 @@ namespace OpenSim.Framework.Communications.Cache yapfile = File.Exists(Path.Combine(Util.dataDir(), "regionassets.yap")); db = Db4oFactory.OpenFile(Path.Combine(Util.dataDir(), "regionassets.yap")); - MainLog.Instance.Verbose("ASSETS", "Db4 Asset database creation"); + m_log.Info("[ASSETS]: Db4 Asset database creation"); if (!yapfile) { @@ -67,7 +69,7 @@ namespace OpenSim.Framework.Communications.Cache if (db != null) { - MainLog.Instance.Verbose("ASSETSERVER", "Closing local asset server database"); + m_log.Info("[ASSETSERVER]: Closing local asset server database"); db.Close(); } } @@ -120,7 +122,7 @@ namespace OpenSim.Framework.Communications.Cache protected virtual void SetUpAssetDatabase() { - MainLog.Instance.Verbose("LOCAL ASSET SERVER", "Setting up asset database"); + m_log.Info("[LOCAL ASSET SERVER]: Setting up asset database"); base.LoadDefaultAssets(); } diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 09f8a0c..1d8f6ba 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -37,6 +37,8 @@ namespace OpenSim.Framework.Communications.Cache { public abstract class AssetServerBase : IAssetServer { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + protected IAssetReceiver m_receiver; protected BlockingQueue m_assetRequests; protected Thread m_localAssetServerThread; @@ -68,15 +70,15 @@ namespace OpenSim.Framework.Communications.Cache if (asset != null) { - //MainLog.Instance.Verbose( - // "ASSET", "Asset {0} received from asset server", req.AssetID); + //m_log.Info( + // String.Format("[ASSET]: Asset {0} received from asset server", req.AssetID)); m_receiver.AssetReceived(asset, req.IsTexture); } else { - MainLog.Instance.Error( - "ASSET", "Asset {0} not found by asset server", req.AssetID); + m_log.Error( + String.Format("[ASSET]: Asset {0} not found by asset server", req.AssetID)); m_receiver.AssetNotFound(req.AssetID); } @@ -84,7 +86,7 @@ namespace OpenSim.Framework.Communications.Cache public virtual void LoadDefaultAssets() { - MainLog.Instance.Verbose("ASSETSERVER", "Setting up asset database"); + m_log.Info("[ASSETSERVER]: Setting up asset database"); assetLoader.ForEachDefaultXmlAsset(StoreAsset); @@ -94,7 +96,7 @@ namespace OpenSim.Framework.Communications.Cache public AssetServerBase() { - MainLog.Instance.Verbose("ASSETSERVER", "Starting asset storage system"); + m_log.Info("[ASSETSERVER]: Starting asset storage system"); m_assetRequests = new BlockingQueue(); m_localAssetServerThread = new Thread(RunRequests); @@ -114,7 +116,7 @@ namespace OpenSim.Framework.Communications.Cache } catch (Exception e) { - MainLog.Instance.Error("ASSETSERVER", e.Message); + m_log.Error("[ASSETSERVER]: " + e.Message); } } } @@ -131,7 +133,7 @@ namespace OpenSim.Framework.Communications.Cache req.IsTexture = isTexture; m_assetRequests.Enqueue(req); - MainLog.Instance.Verbose("ASSET", "Added {0} to request queue", assetID); + m_log.Info(String.Format("[ASSET]: Added {0} to request queue", assetID)); } public virtual void UpdateAsset(AssetBase asset) diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index 2f0727f..48d9ec8 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -36,6 +36,8 @@ namespace OpenSim.Framework.Communications.Cache { public class GridAssetClient : AssetServerBase { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private string _assetServerUrl; public GridAssetClient(string serverUrl) @@ -50,7 +52,7 @@ namespace OpenSim.Framework.Communications.Cache Stream s = null; try { - MainLog.Instance.Debug("ASSETCACHE", "Querying for {0}", req.AssetID.ToString()); + m_log.Debug(String.Format("[ASSETCACHE]: Querying for {0}", req.AssetID.ToString())); RestClient rc = new RestClient(_assetServerUrl); rc.AddResourcePath("assets"); @@ -70,9 +72,9 @@ namespace OpenSim.Framework.Communications.Cache } catch (Exception e) { - MainLog.Instance.Error("ASSETCACHE", e.Message); - MainLog.Instance.Debug("ASSETCACHE", "Getting asset {0}", req.AssetID.ToString()); - MainLog.Instance.Error("ASSETCACHE", e.StackTrace); + m_log.Error("[ASSETCACHE]: " + e.Message); + m_log.Debug(String.Format("[ASSETCACHE]: Getting asset {0}", req.AssetID.ToString())); + m_log.Error("[ASSETCACHE]: " + e.StackTrace); } return null; @@ -93,19 +95,19 @@ namespace OpenSim.Framework.Communications.Cache // XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); // xs.Serialize(s, asset); // RestClient rc = new RestClient(_assetServerUrl); - MainLog.Instance.Verbose("ASSET", "Storing asset"); + m_log.Info("[ASSET]: Storing asset"); //rc.AddResourcePath("assets"); // rc.RequestMethod = "POST"; // rc.Request(s); - //MainLog.Instance.Verbose("ASSET", "Stored {0}", rc); - MainLog.Instance.Verbose("ASSET", "Sending to " + _assetServerUrl + "/assets/"); + //m_log.Info(String.Format("[ASSET]: Stored {0}", rc)); + m_log.Info("[ASSET]: Sending to " + _assetServerUrl + "/assets/"); RestObjectPoster.BeginPostObject(_assetServerUrl + "/assets/", asset); } catch (Exception e) { - MainLog.Instance.Error("ASSETS", e.Message); + m_log.Error("[ASSETS]: " + e.Message); } } diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index ae07898..46767bb 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -26,12 +26,12 @@ * */ +using System; using System.Collections.Generic; using System.IO; using System.Xml; using libsecondlife; using Nini.Config; - using OpenSim.Framework.Console; namespace OpenSim.Framework.Communications.Cache @@ -42,6 +42,8 @@ namespace OpenSim.Framework.Communications.Cache /// public class LibraryRootFolder : InventoryFolderImpl { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private LLUUID libOwner = new LLUUID("11111111-1111-0000-0000-000100bba000"); /// @@ -53,7 +55,7 @@ namespace OpenSim.Framework.Communications.Cache public LibraryRootFolder() { - MainLog.Instance.Verbose("LIBRARYINVENTORY", "Loading library inventory"); + m_log.Info("[LIBRARYINVENTORY]: Loading library inventory"); agentID = libOwner; folderID = new LLUUID("00000112-000f-0000-0000-000100bba000"); @@ -138,8 +140,8 @@ namespace OpenSim.Framework.Communications.Cache /// protected void LoadLibraries(string librariesControlPath) { - MainLog.Instance.Verbose( - "LIBRARYINVENTORY", "Loading libraries control file {0}", librariesControlPath); + m_log.Info( + String.Format("LIBRARYINVENTORY", "Loading libraries control file {0}", librariesControlPath)); LoadFromFile(librariesControlPath, "Libraries control", ReadLibraryFromConfig); } @@ -186,15 +188,15 @@ namespace OpenSim.Framework.Communications.Cache libraryFolders.Add(folderInfo.folderID, folderInfo); parentFolder.SubFolders.Add(folderInfo.folderID, folderInfo); -// MainLog.Instance.Verbose( -// "LIBRARYINVENTORY", "Adding folder {0} ({1})", folderInfo.name, folderInfo.folderID); +// m_log.Info( +// String.Format("[LIBRARYINVENTORY]: Adding folder {0} ({1})", folderInfo.name, folderInfo.folderID)); } else { - MainLog.Instance.Warn( - "LIBRARYINVENTORY", - "Couldn't add folder {0} ({1}) since parent folder with ID {2} does not exist!", - folderInfo.name, folderInfo.folderID, folderInfo.parentID); + m_log.Warn( + String.Format("[LIBRARYINVENTORY]: " + + "Couldn't add folder {0} ({1}) since parent folder with ID {2} does not exist!", + folderInfo.name, folderInfo.folderID, folderInfo.parentID)); } } @@ -227,10 +229,10 @@ namespace OpenSim.Framework.Communications.Cache } else { - MainLog.Instance.Warn( - "LIBRARYINVENTORY", - "Couldn't add item {0} ({1}) since parent folder with ID {2} does not exist!", - item.inventoryName, item.inventoryID, item.parentFolderID); + m_log.Warn( + String.Format("[LIBRARYINVENTORY]: " + + "Couldn't add item {0} ({1}) since parent folder with ID {2} does not exist!", + item.inventoryName, item.inventoryID, item.parentFolderID)); } } @@ -257,14 +259,14 @@ namespace OpenSim.Framework.Communications.Cache } catch (XmlException e) { - MainLog.Instance.Error( - "LIBRARYINVENTORY", "Error loading {0} : {1}", path, e); + m_log.Error( + String.Format("[LIBRARYINVENTORY]: Error loading {0} : {1}", path, e)); } } else { - MainLog.Instance.Error( - "LIBRARYINVENTORY", "{0} file {1} does not exist!", fileDescription, path); + m_log.Error( + String.Format("[LIBRARYINVENTORY]: {0} file {1} does not exist!", fileDescription, path)); } } diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 0a141c3..d3a283a 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -33,6 +33,8 @@ namespace OpenSim.Framework.Communications.Cache { public class SQLAssetServer : AssetServerBase { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + public SQLAssetServer(string pluginName) { AddPlugin(pluginName); @@ -45,7 +47,7 @@ namespace OpenSim.Framework.Communications.Cache public void AddPlugin(string FileName) { - MainLog.Instance.Verbose("SQLAssetServer", "AssetStorage: Attempting to load " + FileName); + m_log.Info("[SQLAssetServer]: AssetStorage: Attempting to load " + FileName); Assembly pluginAssembly = Assembly.LoadFrom(FileName); foreach (Type pluginType in pluginAssembly.GetTypes()) @@ -61,15 +63,14 @@ namespace OpenSim.Framework.Communications.Cache m_assetProvider = plug; m_assetProvider.Initialise(); - MainLog.Instance.Verbose("AssetStorage", - "Added " + m_assetProvider.Name + " " + - m_assetProvider.Version); + m_log.Info("[AssetStorage]: " + + "Added " + m_assetProvider.Name + " " + + m_assetProvider.Version); } } } } - public override void Close() { base.Close(); @@ -98,4 +99,4 @@ namespace OpenSim.Framework.Communications.Cache m_assetProvider.CommitAssets(); } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 14670fd..79c0c86 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -25,6 +25,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ + +using System; using System.Collections.Generic; using libsecondlife; using OpenSim.Framework.Console; @@ -33,6 +35,8 @@ namespace OpenSim.Framework.Communications.Cache { public class UserProfileCacheService { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + // Fields private readonly CommunicationsManager m_parent; private readonly Dictionary m_userProfiles = new Dictionary(); @@ -69,7 +73,7 @@ namespace OpenSim.Framework.Communications.Cache } else { - MainLog.Instance.Error("USERCACHE", "User profile for user {0} not found", userID); + m_log.Error(String.Format("[USERCACHE]: User profile for user {0} not found", userID)); } } } @@ -229,28 +233,28 @@ namespace OpenSim.Framework.Communications.Cache } else { - MainLog.Instance.Error( - "INVENTORYCACHE", "Could not find root folder for user {0}", remoteClient.Name); + m_log.Error( + String.Format("[INVENTORYCACHE]: Could not find root folder for user {0}", remoteClient.Name)); return; } } else { - MainLog.Instance.Error( - "INVENTORYCACHE", - "Could not find user profile for {0} for folder {1}", - remoteClient.Name, folderID); + m_log.Error( + String.Format("[INVENTORYCACHE]: " + + "Could not find user profile for {0} for folder {1}", + remoteClient.Name, folderID)); return; } // If we've reached this point then we couldn't find the folder, even though the client thinks // it exists - MainLog.Instance.Error( - "INVENTORYCACHE", - "Could not find folder {0} for user {1}", - folderID, remoteClient.Name); + m_log.Error( + String.Format("[INVENTORYCACHE]: " + + "Could not find folder {0} for user {1}", + folderID, remoteClient.Name)); } public void HandlePurgeInventoryDescendents(IClientAPI remoteClient, LLUUID folderID) -- cgit v1.1