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/Framework/AssemblyInfo.cs | 2 +- OpenSim/Framework/AssetConfig.cs | 1 + .../Filesystem/AssetLoaderFileSystem.cs | 18 +- OpenSim/Framework/ClientManager.cs | 11 +- .../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 +- .../Framework/Communications/Capabilities/Caps.cs | 38 +- .../Communications/CommunicationsManager.cs | 12 +- .../Communications/InventoryServiceBase.cs | 24 +- OpenSim/Framework/Communications/LoginResponse.cs | 14 +- OpenSim/Framework/Communications/LoginService.cs | 44 +- .../Communications/RestClient/RestClient.cs | 14 +- .../Framework/Communications/UserManagerBase.cs | 49 +- .../Configuration/HTTP/HTTPConfiguration.cs | 4 +- OpenSim/Framework/ConfigurationMember.cs | 52 +-- OpenSim/Framework/Console/ConsoleBase.cs | 433 +++++++++++++++++ OpenSim/Framework/Console/LogBase.cs | 511 --------------------- OpenSim/Framework/Console/MainConsole.cs | 41 ++ OpenSim/Framework/Console/MainLog.cs | 40 -- OpenSim/Framework/Data.DB4o/DB4oUserData.cs | 12 +- OpenSim/Framework/Data.MSSQL/MSSQLAssetData.cs | 6 +- OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs | 6 +- OpenSim/Framework/Data.MSSQL/MSSQLInventoryData.cs | 34 +- OpenSim/Framework/Data.MSSQL/MSSQLManager.cs | 16 +- OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs | 26 +- OpenSim/Framework/Data.MySQL/MySQLAssetData.cs | 18 +- OpenSim/Framework/Data.MySQL/MySQLDataStore.cs | 74 +-- OpenSim/Framework/Data.MySQL/MySQLGridData.cs | 14 +- OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs | 34 +- OpenSim/Framework/Data.MySQL/MySQLManager.cs | 18 +- OpenSim/Framework/Data.MySQL/MySQLUserData.cs | 28 +- OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs | 12 +- .../Framework/Data.SQLite/SQLiteInventoryStore.cs | 14 +- OpenSim/Framework/Data.SQLite/SQLiteManager.cs | 4 +- OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs | 78 ++-- OpenSim/Framework/Data.SQLite/SQLiteUserData.cs | 18 +- OpenSim/Framework/Data/Properties/AssemblyInfo.cs | 2 +- OpenSim/Framework/EstateSettings.cs | 7 +- OpenSim/Framework/GridConfig.cs | 1 + OpenSim/Framework/InventoryConfig.cs | 2 + OpenSim/Framework/MessageServerConfig.cs | 1 + OpenSim/Framework/RegionInfo.cs | 5 +- .../RegionLoader/Web/RegionLoaderWebServer.cs | 17 +- OpenSim/Framework/Servers/BaseHttpServer.cs | 30 +- OpenSim/Framework/Servers/BaseOpenSimServer.cs | 12 +- OpenSim/Framework/Servers/CheckSumServer.cs | 4 +- OpenSim/Framework/UserConfig.cs | 1 + 52 files changed, 955 insertions(+), 989 deletions(-) create mode 100644 OpenSim/Framework/Console/ConsoleBase.cs delete mode 100644 OpenSim/Framework/Console/LogBase.cs create mode 100644 OpenSim/Framework/Console/MainConsole.cs delete mode 100644 OpenSim/Framework/Console/MainLog.cs (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/AssemblyInfo.cs b/OpenSim/Framework/AssemblyInfo.cs index 1507d67..60c9024 100644 --- a/OpenSim/Framework/AssemblyInfo.cs +++ b/OpenSim/Framework/AssemblyInfo.cs @@ -61,4 +61,4 @@ using System.Runtime.InteropServices; // [assembly : AssemblyVersion("1.0.0.0")] -[assembly : AssemblyFileVersion("1.0.0.0")] \ No newline at end of file +[assembly : AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim/Framework/AssetConfig.cs b/OpenSim/Framework/AssetConfig.cs index 9989bfd..a83981a 100644 --- a/OpenSim/Framework/AssetConfig.cs +++ b/OpenSim/Framework/AssetConfig.cs @@ -27,6 +27,7 @@ */ using System; +using OpenSim.Framework.Console; namespace OpenSim.Framework { diff --git a/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs b/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs index 59db3d6..9026331 100644 --- a/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs +++ b/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs @@ -44,6 +44,8 @@ namespace OpenSim.Framework.AssetLoader.Filesystem { public class AssetLoaderFileSystem : IAssetLoader { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + protected AssetBase CreateAsset(string assetIdStr, string name, string path, bool isImage) { AssetBase asset = new AssetBase( @@ -53,13 +55,13 @@ namespace OpenSim.Framework.AssetLoader.Filesystem if (!String.IsNullOrEmpty(path)) { - MainLog.Instance.Verbose("ASSETS", "Loading: [{0}][{1}]", name, path); + m_log.Info(String.Format("[ASSETS]: Loading: [{0}][{1}]", name, path)); LoadAsset(asset, isImage, path); } else { - MainLog.Instance.Verbose("ASSETS", "Instantiated: [{0}]", name); + m_log.Info(String.Format("[ASSETS]: Instantiated: [{0}]", name)); } return asset; @@ -106,14 +108,12 @@ namespace OpenSim.Framework.AssetLoader.Filesystem } catch (XmlException e) { - MainLog.Instance.Error("ASSETS", "Error loading {0} : {1}", assetSetPath, e); + m_log.Error(String.Format("[ASSETS]: Error loading {0} : {1}", assetSetPath, e)); } } else { - MainLog.Instance.Error( - "ASSETS", - "Asset set control file assets/AssetSets.xml does not exist! No assets loaded."); + m_log.Error("[ASSETS]: Asset set control file assets/AssetSets.xml does not exist! No assets loaded."); } assets.ForEach(action); @@ -126,7 +126,7 @@ namespace OpenSim.Framework.AssetLoader.Filesystem /// protected void LoadXmlAssetSet(string assetSetPath, List assets) { - MainLog.Instance.Verbose("ASSETS", "Loading asset set {0}", assetSetPath); + m_log.Info(String.Format("[ASSETS]: Loading asset set {0}", assetSetPath)); if (File.Exists(assetSetPath)) { @@ -152,12 +152,12 @@ namespace OpenSim.Framework.AssetLoader.Filesystem } catch (XmlException e) { - MainLog.Instance.Error("ASSETS", "Error loading {0} : {1}", assetSetPath, e); + m_log.Error(String.Format("[ASSETS]: Error loading {0} : {1}", assetSetPath, e)); } } else { - MainLog.Instance.Error("ASSETS", "Asset set file {0} does not exist!", assetSetPath); + m_log.Error(String.Format("[ASSETS]: Asset set file {0} does not exist!", assetSetPath)); } } } diff --git a/OpenSim/Framework/ClientManager.cs b/OpenSim/Framework/ClientManager.cs index de7708c..8422c17 100644 --- a/OpenSim/Framework/ClientManager.cs +++ b/OpenSim/Framework/ClientManager.cs @@ -36,11 +36,12 @@ namespace OpenSim.Framework public class ClientManager { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private Dictionary m_clients; public void ForEachClient(ForEachClientDelegate whatToDo) { - // Wasteful, I know IClientAPI[] LocalClients = new IClientAPI[0]; lock (m_clients) @@ -57,7 +58,7 @@ namespace OpenSim.Framework } catch (System.Exception e) { - OpenSim.Framework.Console.MainLog.Instance.Warn("CLIENT", "Unable to do ForEachClient for one of the clients" + "\n Reason: " + e.ToString()); + m_log.Warn("[CLIENT]: Unable to do ForEachClient for one of the clients" + "\n Reason: " + e.ToString()); } } } @@ -116,11 +117,9 @@ namespace OpenSim.Framework } catch (System.Exception e) { - OpenSim.Framework.Console.MainLog.Instance.Error("CLIENT", string.Format("Unable to shutdown circuit for: {0}\n Reason: {1}", agentId, e)); + m_log.Error(string.Format("[CLIENT]: Unable to shutdown circuit for: {0}\n Reason: {1}", agentId, e)); } } - - } private uint[] GetAllCircuits(LLUUID agentId) @@ -134,7 +133,6 @@ namespace OpenSim.Framework m_clients.Values.CopyTo(LocalClients, 0); } - for (int i = 0; i < LocalClients.Length; i++ ) { if (LocalClients[i].AgentId == agentId) @@ -160,7 +158,6 @@ namespace OpenSim.Framework m_clients.Values.CopyTo(LocalClients, 0); } - for (int i = 0; i < LocalClients.Length; i++) { if (LocalClients[i].AgentId != sender.AgentId) 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) diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index f85b4ab..6473c26 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -54,6 +54,8 @@ namespace OpenSim.Region.Capabilities public class Caps { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private string m_httpListenerHostName; private uint m_httpListenPort; @@ -96,7 +98,7 @@ namespace OpenSim.Region.Capabilities /// public void RegisterHandlers() { - MainLog.Instance.Verbose("CAPS", "Registering CAPS handlers"); + m_log.Info("[CAPS]: Registering CAPS handlers"); string capsBase = "/CAPS/" + m_capsObjectPath; try { @@ -115,7 +117,7 @@ namespace OpenSim.Region.Capabilities } catch (Exception e) { - MainLog.Instance.Error("CAPS", e.ToString()); + m_log.Error("[CAPS]: " + e.ToString()); } } @@ -275,7 +277,7 @@ namespace OpenSim.Region.Capabilities { try { -// MainLog.Instance.Debug("CAPS", "request: {0}, path: {1}, param: {2}", request, path, param); +// m_log.Debug(String.Format("[CAPS]: request: {0}, path: {1}, param: {2}", request, path, param)); Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(Helpers.StringToField(request)); LLSDTaskScriptUpdate llsdUpdateRequest = new LLSDTaskScriptUpdate(); @@ -303,16 +305,16 @@ namespace OpenSim.Region.Capabilities uploadResponse.uploader = uploaderURL; uploadResponse.state = "upload"; -// MainLog.Instance.Verbose( -// "CAPS", -// "ScriptTaskInventory response: {0}", -// LLSDHelpers.SerialiseLLSDReply(uploadResponse)); +// m_log.Info( +// String.Format("[CAPS]: " + +// "ScriptTaskInventory response: {0}", +// LLSDHelpers.SerialiseLLSDReply(uploadResponse))); return LLSDHelpers.SerialiseLLSDReply(uploadResponse); } catch (Exception e) { - MainLog.Instance.Error("CAPS", e.ToString()); + m_log.Error("[CAPS]: " + e.ToString()); } return null; @@ -349,10 +351,10 @@ namespace OpenSim.Region.Capabilities uploadResponse.uploader = uploaderURL; uploadResponse.state = "upload"; -// MainLog.Instance.Verbose( -// "CAPS", -// "NoteCardAgentInventory response: {0}", -// LLSDHelpers.SerialiseLLSDReply(uploadResponse)); +// m_log.Info( +// String.Format("[CAPS]: " + +// "NoteCardAgentInventory response: {0}", +// LLSDHelpers.SerialiseLLSDReply(uploadResponse))); return LLSDHelpers.SerialiseLLSDReply(uploadResponse); } @@ -681,10 +683,10 @@ namespace OpenSim.Region.Capabilities { try { -// MainLog.Instance.Verbose( -// "CAPS", -// "TaskInventoryScriptUpdater received data: {0}, path: {1}, param: {2}", -// data, path, param); +// m_log.Info( +// String.Format("[CAPS]: " + +// "TaskInventoryScriptUpdater received data: {0}, path: {1}, param: {2}", +// data, path, param)); string res = String.Empty; LLSDTaskInventoryUploadComplete uploadComplete = new LLSDTaskInventoryUploadComplete(); @@ -707,13 +709,13 @@ namespace OpenSim.Region.Capabilities SaveAssetToFile("updatedtaskscript" + Util.RandomClass.Next(1, 1000) + ".dat", data); } -// MainLog.Instance.Verbose("CAPS", "TaskInventoryScriptUpdater.uploaderCaps res: {0}", res); +// m_log.Info(String.Format("[CAPS]: TaskInventoryScriptUpdater.uploaderCaps res: {0}", res)); return res; } catch (Exception e) { - MainLog.Instance.Error("CAPS", e.ToString()); + m_log.Error("[CAPS]: " + e.ToString()); } // XXX Maybe this should be some meaningful error packet diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index dd7c168..f6cfda7 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -36,6 +36,8 @@ namespace OpenSim.Framework.Communications { public class CommunicationsManager { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + protected IUserService m_userService; public IUserService UserService @@ -114,11 +116,11 @@ namespace OpenSim.Framework.Communications if (cmmdParams.Length < 2) { - firstName = MainLog.Instance.CmdPrompt("First name", "Default"); - lastName = MainLog.Instance.CmdPrompt("Last name", "User"); - password = MainLog.Instance.PasswdPrompt("Password"); - regX = Convert.ToUInt32(MainLog.Instance.CmdPrompt("Start Region X", "1000")); - regY = Convert.ToUInt32(MainLog.Instance.CmdPrompt("Start Region Y", "1000")); + firstName = MainConsole.Instance.CmdPrompt("First name", "Default"); + lastName = MainConsole.Instance.CmdPrompt("Last name", "User"); + password = MainConsole.Instance.PasswdPrompt("Password"); + regX = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region X", "1000")); + regY = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region Y", "1000")); } else { diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index a48988d..897aa9a 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -36,6 +36,8 @@ namespace OpenSim.Framework.Communications { public abstract class InventoryServiceBase : IInventoryServices { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + protected Dictionary m_plugins = new Dictionary(); //protected IAssetServer m_assetServer; @@ -52,7 +54,7 @@ namespace OpenSim.Framework.Communications { if (!String.IsNullOrEmpty(FileName)) { - MainLog.Instance.Verbose("AGENTINVENTORY", "Inventorystorage: Attempting to load " + FileName); + m_log.Info("[AGENTINVENTORY]: Inventorystorage: Attempting to load " + FileName); Assembly pluginAssembly = Assembly.LoadFrom(FileName); foreach (Type pluginType in pluginAssembly.GetTypes()) @@ -67,7 +69,7 @@ namespace OpenSim.Framework.Communications (IInventoryData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); plug.Initialise(); m_plugins.Add(plug.getName(), plug); - MainLog.Instance.Verbose("AGENTINVENTORY", "Added IInventoryData Interface"); + m_log.Info("[AGENTINVENTORY]: Added IInventoryData Interface"); } } } @@ -95,9 +97,8 @@ namespace OpenSim.Framework.Communications rootFolder = plugin.Value.getUserRootFolder(userID); if (rootFolder != null) { - MainLog.Instance.Verbose( - "INVENTORY", - "Found root folder for user with ID " + userID + ". Retrieving inventory contents."); + m_log.Info( + "[INVENTORY]: Found root folder for user with ID " + userID + ". Retrieving inventory contents."); inventoryList = plugin.Value.getInventoryFolders(rootFolder.folderID); inventoryList.Insert(0, rootFolder); @@ -105,8 +106,8 @@ namespace OpenSim.Framework.Communications } } - MainLog.Instance.Warn( - "INVENTORY", "Could not find a root folder belonging to user with ID " + userID); + m_log.Warn( + "[INVENTORY]: Could not find a root folder belonging to user with ID " + userID); return inventoryList; } @@ -226,10 +227,10 @@ namespace OpenSim.Framework.Communications if (null != existingRootFolder) { - MainLog.Instance.Error( - "AGENTINVENTORY", - "Did not create a new inventory for user {0} since they already have " - + "a root inventory folder with id {1}", user, existingRootFolder); + m_log.Error( + String.Format("[AGENTINVENTORY]: " + + "Did not create a new inventory for user {0} since they already have " + + "a root inventory folder with id {1}", user, existingRootFolder)); } else { @@ -251,6 +252,7 @@ namespace OpenSim.Framework.Communications public virtual void CreateNewInventorySet(LLUUID user) { InventoryFolderBase folder = new InventoryFolderBase(); + folder.parentID = LLUUID.Zero; folder.agentID = user; folder.folderID = LLUUID.Random(); diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index 7f8658d..9036884 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -42,6 +42,8 @@ namespace OpenSim.Framework.UserManagement /// public class LoginResponse { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private Hashtable loginFlagsHash; private Hashtable globalTexturesHash; private Hashtable loginError; @@ -362,10 +364,8 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Warn( - "CLIENT", - "LoginResponse: Error creating XML-RPC Response: " + e.Message - ); + m_log.Warn("[CLIENT]: LoginResponse: Error creating XML-RPC Response: " + e.Message); + return (GenerateFailureResponse("Internal Error", "Error generating Login Response", "false")); } } // ToXmlRpcResponse @@ -461,10 +461,8 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Warn( - "CLIENT", - "LoginResponse: Error creating XML-RPC Response: " + e.Message - ); + m_log.Warn("[CLIENT]: LoginResponse: Error creating XML-RPC Response: " + e.Message); + return GenerateFailureResponseLLSD("Internal Error", "Error generating Login Response", "false"); } } diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 865349f..db86a97 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -44,6 +44,8 @@ namespace OpenSim.Framework.UserManagement { public class LoginService { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + protected string m_welcomeMessage = "Welcome to OpenSim"; protected UserManagerBase m_userManager = null; protected Mutex m_loginMutex = new Mutex(false); @@ -83,7 +85,7 @@ namespace OpenSim.Framework.UserManagement try { //CFK: CustomizeResponse contains sufficient strings to alleviate the need for this. - //CKF: MainLog.Instance.Verbose("LOGIN", "Attempting login now..."); + //CKF: m_log.Info("[LOGIN]: Attempting login now..."); XmlRpcResponse response = new XmlRpcResponse(); Hashtable requestData = (Hashtable) request.Params[0]; @@ -102,16 +104,14 @@ namespace OpenSim.Framework.UserManagement if( requestData.Contains("version")) { string clientversion = (string)requestData["version"]; - MainLog.Instance.Verbose("LOGIN","Client Version " + clientversion + " for " + firstname + " " + lastname); + m_log.Info("[LOGIN]: Client Version " + clientversion + " for " + firstname + " " + lastname); } userProfile = GetTheUser(firstname, lastname); if (userProfile == null) { - MainLog.Instance.Verbose( - "LOGIN", - "Could not find a profile for " + firstname + " " + lastname); + m_log.Info("[LOGIN]: Could not find a profile for " + firstname + " " + lastname); return logResponse.CreateLoginFailedResponse(); } @@ -213,7 +213,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose("LOGIN", e.ToString()); + m_log.Info("[LOGIN]: " + e.ToString()); return logResponse.CreateDeadRegionResponse(); //return logResponse.ToXmlRpcResponse(); } @@ -225,10 +225,9 @@ namespace OpenSim.Framework.UserManagement return logResponse.ToXmlRpcResponse(); } - - catch (Exception E) + catch (Exception e) { - MainLog.Instance.Verbose("LOGIN", E.ToString()); + m_log.Info("[LOGIN]: " + e.ToString()); } //} } @@ -265,9 +264,7 @@ namespace OpenSim.Framework.UserManagement userProfile = GetTheUser(firstname, lastname); if (userProfile == null) { - MainLog.Instance.Verbose( - "LOGIN", - "Could not find a profile for " + firstname + " " + lastname); + m_log.Info("[LOGIN]: Could not find a profile for " + firstname + " " + lastname); return logResponse.CreateLoginFailedResponseLLSD(); } @@ -345,7 +342,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception ex) { - MainLog.Instance.Verbose("LOGIN", ex.ToString()); + m_log.Info("[LOGIN]: " + ex.ToString()); return logResponse.CreateDeadRegionResponseLLSD(); } @@ -359,7 +356,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception ex) { - MainLog.Instance.Verbose("LOGIN", ex.ToString()); + m_log.Info("[LOGIN]: " + ex.ToString()); return logResponse.CreateFailedResponseLLSD(); } } @@ -458,7 +455,7 @@ namespace OpenSim.Framework.UserManagement string redirectURL = "about:blank?redirect-http-hack=" + System.Web.HttpUtility.UrlEncode("secondlife:///app/login?first_name=" + firstname + "&last_name=" + lastname + "&location=" + location + "&grid=Other&web_login_key=" + webloginkey.ToString()); - //MainLog.Instance.Verbose("WEB", "R:" + redirectURL); + //m_log.Info("[WEB]: R:" + redirectURL); returnactions["int_response_code"] = statuscode; returnactions["str_redirect_location"] = redirectURL; returnactions["str_response_string"] = "GoodLogin"; @@ -604,27 +601,22 @@ namespace OpenSim.Framework.UserManagement public virtual bool AuthenticateUser(UserProfileData profile, string password) { bool passwordSuccess = false; - MainLog.Instance.Verbose( - "LOGIN", "Authenticating {0} {1} ({2})", profile.username, profile.surname, profile.UUID); + m_log.Info( + String.Format("[LOGIN]: Authenticating {0} {1} ({2})", profile.username, profile.surname, profile.UUID)); // Web Login method seems to also occasionally send the hashed password itself - // we do this to get our hash in a form that the server password code can consume // when the web-login-form submits the password in the clear (supposed to be over SSL!) if (!password.StartsWith("$1$")) password = "$1$" + Util.Md5Hash(password); - - password = password.Remove(0, 3); //remove $1$ - - string s = Util.Md5Hash(password + ":" + profile.passwordSalt); // Testing... - //MainLog.Instance.Verbose("LOGIN", "SubHash:" + s + " userprofile:" + profile.passwordHash); - //MainLog.Instance.Verbose("LOGIN", "userprofile:" + profile.passwordHash + " SubCT:" + password); + //m_log.Info("[LOGIN]: SubHash:" + s + " userprofile:" + profile.passwordHash); + //m_log.Info("[LOGIN]: userprofile:" + profile.passwordHash + " SubCT:" + password); passwordSuccess = (profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) || profile.passwordHash.Equals(password,StringComparison.InvariantCultureIgnoreCase)); @@ -635,8 +627,8 @@ namespace OpenSim.Framework.UserManagement public virtual bool AuthenticateUser(UserProfileData profile, LLUUID webloginkey) { bool passwordSuccess = false; - MainLog.Instance.Verbose( - "LOGIN", "Authenticating {0} {1} ({2})", profile.username, profile.surname, profile.UUID); + m_log.Info( + String.Format("[LOGIN]: Authenticating {0} {1} ({2})", profile.username, profile.surname, profile.UUID)); // Match web login key unless it's the default weblogin key LLUUID.Zero passwordSuccess = ((profile.webLoginKey==webloginkey) && profile.webLoginKey != LLUUID.Zero); diff --git a/OpenSim/Framework/Communications/RestClient/RestClient.cs b/OpenSim/Framework/Communications/RestClient/RestClient.cs index 76bad64..f968c9a 100644 --- a/OpenSim/Framework/Communications/RestClient/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient/RestClient.cs @@ -56,6 +56,8 @@ namespace OpenSim.Framework.Communications /// public class RestClient { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private string realuri; #region member variables @@ -238,7 +240,7 @@ namespace OpenSim.Framework.Communications } } realuri = sb.ToString(); - MainLog.Instance.Verbose("REST", "RestURL: {0}", realuri); + m_log.Info(String.Format("[REST]: RestURL: {0}", realuri)); return new Uri(sb.ToString()); } @@ -374,16 +376,16 @@ namespace OpenSim.Framework.Communications _asyncException = null; _request.ContentLength = src.Length; - MainLog.Instance.Verbose("REST", "Request Length {0}", _request.ContentLength); - MainLog.Instance.Verbose("REST", "Sending Web Request {0}", buildUri()); + m_log.Info(String.Format("[REST]: Request Length {0}", _request.ContentLength)); + m_log.Info(String.Format("[REST]: Sending Web Request {0}", buildUri())); src.Seek(0, SeekOrigin.Begin); - MainLog.Instance.Verbose("REST", "Seek is ok"); + m_log.Info("[REST]: Seek is ok"); Stream dst = _request.GetRequestStream(); - MainLog.Instance.Verbose("REST", "GetRequestStream is ok"); + m_log.Info("[REST]: GetRequestStream is ok"); byte[] buf = new byte[1024]; int length = src.Read(buf, 0, 1024); - MainLog.Instance.Verbose("REST", "First Read is ok"); + m_log.Info("[REST]: First Read is ok"); while (length > 0) { dst.Write(buf, 0, length); diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 3b1d837..edab6ae 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -43,6 +43,8 @@ namespace OpenSim.Framework.UserManagement /// public abstract class UserManagerBase : IUserService { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + public UserConfig _config; private Dictionary _plugins = new Dictionary(); @@ -54,10 +56,10 @@ namespace OpenSim.Framework.UserManagement { if (!String.IsNullOrEmpty(FileName)) { - MainLog.Instance.Verbose("USERSTORAGE", "Attempting to load " + FileName); + m_log.Info("[USERSTORAGE]: Attempting to load " + FileName); Assembly pluginAssembly = Assembly.LoadFrom(FileName); - MainLog.Instance.Verbose("USERSTORAGE", "Found " + pluginAssembly.GetTypes().Length + " interfaces."); + m_log.Info("[USERSTORAGE]: Found " + pluginAssembly.GetTypes().Length + " interfaces."); foreach (Type pluginType in pluginAssembly.GetTypes()) { if (!pluginType.IsAbstract) @@ -79,7 +81,7 @@ namespace OpenSim.Framework.UserManagement { plug.Initialise(); _plugins.Add(plug.getName(), plug); - MainLog.Instance.Verbose("USERSTORAGE", "Added IUserData Interface"); + m_log.Info("[USERSTORAGE]: Added IUserData Interface"); } #region Get UserProfile @@ -116,8 +118,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception) { - MainLog.Instance.Verbose("USERSTORAGE", - "Unable to generate AgentPickerData via " + plugin.Key + "(" + query + ")"); + m_log.Info("[USERSTORAGE]: Unable to generate AgentPickerData via " + plugin.Key + "(" + query + ")"); return new List(); } } @@ -163,8 +164,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose("USERSTORAGE", - "Unable to set user via " + plugin.Key + "(" + e.ToString() + ")"); + m_log.Info("[USERSTORAGE]: Unable to set user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -190,8 +190,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose("USERSTORAGE", - "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + m_log.Info("[USERSTORAGE]: Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -214,8 +213,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose("USERSTORAGE", - "Unable to GetUserFriendList via " + plugin.Key + "(" + e.ToString() + ")"); + m_log.Info("[USERSTORAGE]: Unable to GetUserFriendList via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -234,8 +232,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose("USERSTORAGE", - "Unable to Store WebLoginKey via " + plugin.Key + "(" + e.ToString() + ")"); + m_log.Info("[USERSTORAGE]: Unable to Store WebLoginKey via " + plugin.Key + "(" + e.ToString() + ")"); } } } @@ -250,8 +247,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose("USERSTORAGE", - "Unable to AddNewUserFriend via " + plugin.Key + "(" + e.ToString() + ")"); + m_log.Info("[USERSTORAGE]: Unable to AddNewUserFriend via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -268,8 +264,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose("USERSTORAGE", - "Unable to RemoveUserFriend via " + plugin.Key + "(" + e.ToString() + ")"); + m_log.Info("[USERSTORAGE]: Unable to RemoveUserFriend via " + plugin.Key + "(" + e.ToString() + ")"); } } } @@ -284,8 +279,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose("USERSTORAGE", - "Unable to UpdateUserFriendPerms via " + plugin.Key + "(" + e.ToString() + ")"); + m_log.Info("[USERSTORAGE]: Unable to UpdateUserFriendPerms via " + plugin.Key + "(" + e.ToString() + ")"); } } } @@ -304,8 +298,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose("USERSTORAGE", - "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + m_log.Info("[USERSTORAGE]: Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -337,8 +330,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose("USERSTORAGE", - "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + m_log.Info("[USERSTORAGE]: Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -454,14 +446,14 @@ namespace OpenSim.Framework.UserManagement } else { - MainLog.Instance.Verbose("LOGOUT", "didn't save logout position, currentAgent is null *do Fix "); + m_log.Info("[LOGOUT]: didn't save logout position, currentAgent is null *do Fix "); } - MainLog.Instance.Verbose("LOGOUT", userProfile.username + " " + userProfile.surname + " from " + regionhandle + "(" + posx + "," + posy + "," + posz + ")" ); - MainLog.Instance.Verbose("LOGOUT", "userid: " + userid.ToString() + " regionid: " + regionid.ToString() ); + m_log.Info("[LOGOUT]: " + userProfile.username + " " + userProfile.surname + " from " + regionhandle + "(" + posx + "," + posy + "," + posz + ")" ); + m_log.Info("[LOGOUT]: userid: " + userid.ToString() + " regionid: " + regionid.ToString() ); } else { - MainLog.Instance.Warn("LOGOUT", "Unknown User logged out"); + m_log.Warn("[LOGOUT]: Unknown User logged out"); } } @@ -539,8 +531,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose("USERSTORAGE", - "Unable to add user via " + plugin.Key + "(" + e.ToString() + ")"); + m_log.Info("[USERSTORAGE]: Unable to add user via " + plugin.Key + "(" + e.ToString() + ")"); } } diff --git a/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs b/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs index e27c88b..a657c3a 100644 --- a/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs +++ b/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs @@ -35,6 +35,8 @@ namespace OpenSim.Framework.Configuration.HTTP { public class HTTPConfiguration : IGenericConfig { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private RemoteConfigSettings remoteConfigSettings; private XmlConfiguration xmlConfig; @@ -81,7 +83,7 @@ namespace OpenSim.Framework.Configuration.HTTP } catch (WebException) { - MainLog.Instance.Warn("Unable to connect to remote configuration file (" + + m_log.Warn("Unable to connect to remote configuration file (" + remoteConfigSettings.baseConfigURL + configFileName + "). Creating local file instead."); xmlConfig.SetFileName(configFileName); diff --git a/OpenSim/Framework/ConfigurationMember.cs b/OpenSim/Framework/ConfigurationMember.cs index 7590495..921fb66 100644 --- a/OpenSim/Framework/ConfigurationMember.cs +++ b/OpenSim/Framework/ConfigurationMember.cs @@ -39,6 +39,8 @@ namespace OpenSim.Framework { public class ConfigurationMember { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + public delegate bool ConfigurationOptionResult(string configuration_key, object configuration_result); public delegate void ConfigurationOptionsLoad(); @@ -110,7 +112,7 @@ namespace OpenSim.Framework } else { - MainLog.Instance.Notice( + m_log.Info( "Required fields for adding a configuration option is invalid. Will not add this option (" + option.configurationKey + ")"); } @@ -147,46 +149,44 @@ namespace OpenSim.Framework checkAndAddConfigOption(configOption); } - // TEMP - REMOVE private int cE = 0; public void performConfigurationRetrieve() { if (cE > 1) - MainLog.Instance.Error("READING CONFIGURATION COUT: " + cE.ToString()); + m_log.Error("READING CONFIGURATION COUT: " + cE.ToString()); configurationPlugin = LoadConfigDll(configurationPluginFilename); configurationOptions.Clear(); if (loadFunction == null) { - MainLog.Instance.Error("Load Function for '" + configurationDescription + + m_log.Error("Load Function for '" + configurationDescription + "' is null. Refusing to run configuration."); return; } if (resultFunction == null) { - MainLog.Instance.Error("Result Function for '" + configurationDescription + + m_log.Error("Result Function for '" + configurationDescription + "' is null. Refusing to run configuration."); return; } - MainLog.Instance.Verbose("CONFIG", "Calling Configuration Load Function..."); + m_log.Info("[CONFIG]: Calling Configuration Load Function..."); loadFunction(); if (configurationOptions.Count <= 0) { - MainLog.Instance.Error("CONFIG", - "No configuration options were specified for '" + configurationOptions + - "'. Refusing to continue configuration."); + m_log.Error("[CONFIG]: No configuration options were specified for '" + configurationOptions + + "'. Refusing to continue configuration."); return; } bool useFile = true; if (configurationPlugin == null) { - MainLog.Instance.Error("CONFIG", "Configuration Plugin NOT LOADED!"); + m_log.Error("[CONFIG]: Configuration Plugin NOT LOADED!"); return; } @@ -200,7 +200,7 @@ namespace OpenSim.Framework } catch (XmlException e) { - MainLog.Instance.Error("Error loading " + configurationFilename + ": " + e.ToString()); + m_log.Error("Error loading " + configurationFilename + ": " + e.ToString()); useFile = false; } } @@ -208,11 +208,11 @@ namespace OpenSim.Framework { if (configurationFromXMLNode != null) { - MainLog.Instance.Notice("Loading from XML Node, will not save to the file"); + m_log.Info("Loading from XML Node, will not save to the file"); configurationPlugin.LoadDataFromString(configurationFromXMLNode.OuterXml); } - MainLog.Instance.Notice("XML Configuration Filename is not valid; will not save to the file."); + m_log.Info("XML Configuration Filename is not valid; will not save to the file."); useFile = false; } @@ -253,15 +253,15 @@ namespace OpenSim.Framework if (configurationDescription.Trim() != String.Empty) { console_result = - MainLog.Instance.CmdPrompt( + MainConsole.Instance.CmdPrompt( configurationDescription + ": " + configOption.configurationQuestion, configOption.configurationDefault); } else { console_result = - MainLog.Instance.CmdPrompt(configOption.configurationQuestion, - configOption.configurationDefault); + MainConsole.Instance.CmdPrompt(configOption.configurationQuestion, + configOption.configurationDefault); } } else @@ -431,7 +431,7 @@ namespace OpenSim.Framework if (!resultFunction(configOption.configurationKey, return_result)) { - MainLog.Instance.Notice( + m_log.Info( "The handler for the last configuration option denied that input, please try again."); convertSuccess = false; ignoreNextFromConfig = true; @@ -441,20 +441,18 @@ namespace OpenSim.Framework { if (configOption.configurationUseDefaultNoPrompt) { - MainLog.Instance.Error("CONFIG", - string.Format( - "[{3}]:[{1}] is not valid default for parameter [{0}].\nThe configuration result must be parsable to {2}.\n", - configOption.configurationKey, console_result, errorMessage, - configurationFilename)); + m_log.Error(string.Format( + "[CONFIG]: [{3}]:[{1}] is not valid default for parameter [{0}].\nThe configuration result must be parsable to {2}.\n", + configOption.configurationKey, console_result, errorMessage, + configurationFilename)); convertSuccess = true; } else { - MainLog.Instance.Warn("CONFIG", - string.Format( - "[{3}]:[{1}] is not a valid value [{0}].\nThe configuration result must be parsable to {2}.\n", - configOption.configurationKey, console_result, errorMessage, - configurationFilename)); + m_log.Warn(string.Format( + "[CONFIG]: [{3}]:[{1}] is not a valid value [{0}].\nThe configuration result must be parsable to {2}.\n", + configOption.configurationKey, console_result, errorMessage, + configurationFilename)); ignoreNextFromConfig = true; } } diff --git a/OpenSim/Framework/Console/ConsoleBase.cs b/OpenSim/Framework/Console/ConsoleBase.cs new file mode 100644 index 0000000..3f68e50 --- /dev/null +++ b/OpenSim/Framework/Console/ConsoleBase.cs @@ -0,0 +1,433 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Net; + +namespace OpenSim.Framework.Console +{ + public class ConsoleBase + { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + + private object m_syncRoot = new object(); + + public conscmd_callback m_cmdParser; + public string m_componentName; + + public ConsoleBase(string componentname, conscmd_callback cmdparser) + { + m_componentName = componentname; + m_cmdParser = cmdparser; + + System.Console.WriteLine("Creating new local console"); + + m_log.Info("[" + m_componentName + "]: Started at " + DateTime.Now.ToString()); + } + + public void Close() + { + m_log.Info("[" + m_componentName + "]: Shutdown at " + DateTime.Now.ToString()); + } + + /// + /// derive an ansi color from a string, ignoring the darker colors. + /// This is used to help automatically bin component tags with colors + /// in various print functions. + /// + /// arbitrary string for input + /// an ansii color + private ConsoleColor DeriveColor(string input) + { + int colIdx = (input.ToUpper().GetHashCode() % 6) + 9; + return (ConsoleColor) colIdx; + } + + /// + /// Sends a warning to the current console output + /// + /// The message to send + /// WriteLine-style message arguments + public void Warn(string format, params object[] args) + { + WriteNewLine(ConsoleColor.Yellow, format, args); + } + + /// + /// Sends a warning to the current console output + /// + /// The module that sent this message + /// The message to send + /// WriteLine-style message arguments + public void Warn(string sender, string format, params object[] args) + { + WritePrefixLine(DeriveColor(sender), sender); + WriteNewLine(ConsoleColor.Yellow, format, args); + } + + /// + /// Sends a notice to the current console output + /// + /// The message to send + /// WriteLine-style message arguments + public void Notice(string format, params object[] args) + { + WriteNewLine(ConsoleColor.White, format, args); + } + + /// + /// Sends a notice to the current console output + /// + /// The module that sent this message + /// The message to send + /// WriteLine-style message arguments + public void Notice(string sender, string format, params object[] args) + { + WritePrefixLine(DeriveColor(sender), sender); + WriteNewLine(ConsoleColor.White, format, args); + } + + /// + /// Sends an error to the current console output + /// + /// The message to send + /// WriteLine-style message arguments + public void Error(string format, params object[] args) + { + WriteNewLine(ConsoleColor.Red, format, args); + } + + /// + /// Sends an error to the current console output + /// + /// The module that sent this message + /// The message to send + /// WriteLine-style message arguments + public void Error(string sender, string format, params object[] args) + { + WritePrefixLine(DeriveColor(sender), sender); + Error(format, args); + } + + /// + /// Sends a status message to the current console output + /// + /// The message to send + /// WriteLine-style message arguments + public void Status(string format, params object[] args) + { + WriteNewLine(ConsoleColor.Blue, format, args); + } + + /// + /// Sends a status message to the current console output + /// + /// The module that sent this message + /// The message to send + /// WriteLine-style message arguments + public void Status(string sender, string format, params object[] args) + { + WritePrefixLine(DeriveColor(sender), sender); + WriteNewLine(ConsoleColor.Blue, format, args); + } + + [Conditional("DEBUG")] + public void Debug(string format, params object[] args) + { + WriteNewLine(ConsoleColor.Gray, format, args); + } + + [Conditional("DEBUG")] + public void Debug(string sender, string format, params object[] args) + { + WritePrefixLine(DeriveColor(sender), sender); + WriteNewLine(ConsoleColor.Gray, format, args); + } + + private void WriteNewLine(ConsoleColor color, string format, params object[] args) + { + try + { + lock (m_syncRoot) + { + try + { + System.Console.WriteLine(format, args); + } + + catch (FormatException) + { + System.Console.WriteLine(args); + } + + try + { + if (color != ConsoleColor.White) + System.Console.ForegroundColor = color; + + System.Console.WriteLine(format, args); + System.Console.ResetColor(); + } + catch (ArgumentNullException) + { + // Some older systems dont support coloured text. + System.Console.WriteLine(format, args); + } + catch (FormatException) + { + // Some older systems dont support coloured text. + System.Console.WriteLine(args); + } + } + } + catch (ObjectDisposedException) + { + } + } + + private void WritePrefixLine(ConsoleColor color, string sender) + { + try + { + lock (m_syncRoot) + { + sender = sender.ToUpper(); + + System.Console.WriteLine("[" + sender + "] "); + + System.Console.Write("["); + + try + { + System.Console.ForegroundColor = color; + System.Console.Write(sender); + System.Console.ResetColor(); + } + catch (ArgumentNullException) + { + // Some older systems dont support coloured text. + System.Console.WriteLine(sender); + } + + System.Console.Write("] \t"); + } + } + catch (ObjectDisposedException) + { + } + } + + public string ReadLine() + { + try + { + return System.Console.ReadLine(); + } + catch (Exception e) + { + m_log.Error("[Console]: System.Console.ReadLine exception " + e.ToString()); + return String.Empty; + } + } + + public int Read() + { + return System.Console.Read(); + } + + public IPAddress CmdPromptIPAddress(string prompt, string defaultvalue) + { + IPAddress address; + string addressStr; + + while (true) + { + addressStr = CmdPrompt(prompt, defaultvalue); + if (IPAddress.TryParse(addressStr, out address)) + { + break; + } + else + { + m_log.Error("Illegal address. Please re-enter."); + } + } + + return address; + } + + public uint CmdPromptIPPort(string prompt, string defaultvalue) + { + uint port; + string portStr; + + while (true) + { + portStr = CmdPrompt(prompt, defaultvalue); + if (uint.TryParse(portStr, out port)) + { + if (port >= IPEndPoint.MinPort && port <= IPEndPoint.MaxPort) + { + break; + } + } + + m_log.Error("Illegal address. Please re-enter."); + } + + return port; + } + + // Displays a prompt and waits for the user to enter a string, then returns that string + // Done with no echo and suitable for passwords + public string PasswdPrompt(string prompt) + { + // FIXME: Needs to be better abstracted + ConsoleColor oldfg = System.Console.ForegroundColor; + System.Console.ForegroundColor = System.Console.BackgroundColor; + string temp = System.Console.ReadLine(); + System.Console.ForegroundColor = oldfg; + return temp; + } + + // Displays a command prompt and waits for the user to enter a string, then returns that string + public string CmdPrompt(string prompt) + { + System.Console.WriteLine(String.Format("{0}: ", prompt)); + return ReadLine(); + } + + // Displays a command prompt and returns a default value if the user simply presses enter + public string CmdPrompt(string prompt, string defaultresponse) + { + string temp = CmdPrompt(String.Format("{0} [{1}]", prompt, defaultresponse)); + if (temp == String.Empty) + { + return defaultresponse; + } + else + { + return temp; + } + } + + // Displays a command prompt and returns a default value, user may only enter 1 of 2 options + public string CmdPrompt(string prompt, string defaultresponse, string OptionA, string OptionB) + { + bool itisdone = false; + string temp = CmdPrompt(prompt, defaultresponse); + while (itisdone == false) + { + if ((temp == OptionA) || (temp == OptionB)) + { + itisdone = true; + } + else + { + System.Console.WriteLine("Valid options are " + OptionA + " or " + OptionB); + temp = CmdPrompt(prompt, defaultresponse); + } + } + return temp; + } + + // Runs a command with a number of parameters + public Object RunCmd(string Cmd, string[] cmdparams) + { + m_cmdParser.RunCmd(Cmd, cmdparams); + return null; + } + + // Shows data about something + public void ShowCommands(string ShowWhat) + { + m_cmdParser.Show(ShowWhat); + } + + public void Prompt() + { + string tempstr = CmdPrompt(m_componentName + "# "); + RunCommand(tempstr); + } + + public void RunCommand(string command) + { + string[] tempstrarray; + tempstrarray = command.Split(' '); + string cmd = tempstrarray[0]; + Array.Reverse(tempstrarray); + Array.Resize(ref tempstrarray, tempstrarray.Length - 1); + Array.Reverse(tempstrarray); + string[] cmdparams = (string[]) tempstrarray; + try + { + RunCmd(cmd, cmdparams); + } + catch (Exception e) + { + m_log.Error("[Console]: Command failed with exception " + e.ToString()); + } + } + + public string LineInfo + { + get + { + string result = String.Empty; + + string stacktrace = Environment.StackTrace; + List lines = new List(stacktrace.Split(new string[] {"at "}, StringSplitOptions.None)); + + if (lines.Count > 4) + { + lines.RemoveRange(0, 4); + + string tmpLine = lines[0]; + + int inIndex = tmpLine.IndexOf(" in "); + + if (inIndex > -1) + { + result = tmpLine.Substring(0, inIndex); + + int lineIndex = tmpLine.IndexOf(":line "); + + if (lineIndex > -1) + { + lineIndex += 6; + result += ", line " + tmpLine.Substring(lineIndex, (tmpLine.Length - lineIndex) - 5); + } + } + } + return result; + } + } + } +} diff --git a/OpenSim/Framework/Console/LogBase.cs b/OpenSim/Framework/Console/LogBase.cs deleted file mode 100644 index a2c4b3a..0000000 --- a/OpenSim/Framework/Console/LogBase.cs +++ /dev/null @@ -1,511 +0,0 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Net; - -namespace OpenSim.Framework.Console -{ - public enum LogPriority : int - { - CRITICAL, - HIGH, - MEDIUM, - NORMAL, - LOW, - VERBOSE, - EXTRAVERBOSE - } - - public class LogBase - { - private object m_syncRoot = new object(); - - private StreamWriter Log; - public conscmd_callback cmdparser; - public string componentname; - private bool m_verbose; - - public LogBase(string LogFile, string componentname, conscmd_callback cmdparser, bool verbose) - { - this.componentname = componentname; - this.cmdparser = cmdparser; - m_verbose = verbose; - System.Console.WriteLine("Creating new local console"); - - if (String.IsNullOrEmpty(LogFile)) - { - LogFile = componentname + ".log"; - } - - System.Console.WriteLine("Logs will be saved to current directory in " + LogFile); - - try - { - Log = File.AppendText(LogFile); - } - catch (Exception ex) - { - System.Console.WriteLine("Unable to open log file. Do you already have another copy of OpenSim running? Permission problem?"); - System.Console.WriteLine(ex.Message); - System.Console.WriteLine(""); - System.Console.WriteLine("Application is terminating."); - System.Console.WriteLine(""); - System.Threading.Thread.CurrentThread.Abort(); - } - Log.WriteLine("========================================================================"); - Log.WriteLine(componentname + " Started at " + DateTime.Now.ToString()); - } - - public void Close() - { - Log.WriteLine("Shutdown at " + DateTime.Now.ToString()); - Log.Close(); - } - - /// - /// derive an ansi color from a string, ignoring the darker colors. - /// This is used to help automatically bin component tags with colors - /// in various print functions. - /// - /// arbitrary string for input - /// an ansii color - private ConsoleColor DeriveColor(string input) - { - int colIdx = (input.ToUpper().GetHashCode()%6) + 9; - return (ConsoleColor) colIdx; - } - - /// - /// Sends a warning to the current log output - /// - /// The message to send - /// WriteLine-style message arguments - public void Warn(string format, params object[] args) - { - WriteNewLine(ConsoleColor.Yellow, format, args); - return; - } - - /// - /// Sends a warning to the current log output - /// - /// The module that sent this message - /// The message to send - /// WriteLine-style message arguments - public void Warn(string sender, string format, params object[] args) - { - WritePrefixLine(DeriveColor(sender), sender); - WriteNewLine(ConsoleColor.Yellow, format, args); - return; - } - - /// - /// Sends a notice to the current log output - /// - /// The message to send - /// WriteLine-style message arguments - public void Notice(string format, params object[] args) - { - WriteNewLine(ConsoleColor.White, format, args); - return; - } - - /// - /// Sends a notice to the current log output - /// - /// The module that sent this message - /// The message to send - /// WriteLine-style message arguments - public void Notice(string sender, string format, params object[] args) - { - WritePrefixLine(DeriveColor(sender), sender); - WriteNewLine(ConsoleColor.White, format, args); - return; - } - - /// - /// Sends an error to the current log output - /// - /// The message to send - /// WriteLine-style message arguments - public void Error(string format, params object[] args) - { - WriteNewLine(ConsoleColor.Red, format, args); - return; - } - - /// - /// Sends an error to the current log output - /// - /// The module that sent this message - /// The message to send - /// WriteLine-style message arguments - public void Error(string sender, string format, params object[] args) - { - WritePrefixLine(DeriveColor(sender), sender); - Error(format, args); - return; - } - - /// - /// Sends an informational message to the current log output - /// - /// The module that sent this message - /// The message to send - /// WriteLine-style message arguments - public void Verbose(string sender, string format, params object[] args) - { - if (m_verbose) - { - WritePrefixLine(DeriveColor(sender), sender); - WriteNewLine(ConsoleColor.Gray, format, args); - return; - } - } - - /// - /// Sends a status message to the current log output - /// - /// The message to send - /// WriteLine-style message arguments - public void Status(string format, params object[] args) - { - WriteNewLine(ConsoleColor.Blue, format, args); - return; - } - - /// - /// Sends a status message to the current log output - /// - /// The module that sent this message - /// The message to send - /// WriteLine-style message arguments - public void Status(string sender, string format, params object[] args) - { - WritePrefixLine(DeriveColor(sender), sender); - WriteNewLine(ConsoleColor.Blue, format, args); - return; - } - - [Conditional("DEBUG")] - public void Debug(string format, params object[] args) - { - WriteNewLine(ConsoleColor.Gray, format, args); - return; - } - - [Conditional("DEBUG")] - public void Debug(string sender, string format, params object[] args) - { - WritePrefixLine(DeriveColor(sender), sender); - WriteNewLine(ConsoleColor.Gray, format, args); - return; - } - - private void WriteNewLine(ConsoleColor color, string format, params object[] args) - { - try - { - lock (m_syncRoot) - { - string now = DateTime.Now.ToString("[MM-dd HH:mm:ss] "); - Log.Write(now); - try - { - Log.WriteLine(format, args); - Log.Flush(); - } - - catch (FormatException) - { - System.Console.WriteLine(args); - } - System.Console.Write(now); - try - { - if (color != ConsoleColor.White) - System.Console.ForegroundColor = color; - - System.Console.WriteLine(format, args); - System.Console.ResetColor(); - } - catch (ArgumentNullException) - { - // Some older systems dont support coloured text. - System.Console.WriteLine(format, args); - } - catch (FormatException) - { - // Some older systems dont support coloured text. - System.Console.WriteLine(args); - } - - return; - } - } - catch (ObjectDisposedException) - { - return; - } - } - - private void WritePrefixLine(ConsoleColor color, string sender) - { - try - { - lock (m_syncRoot) - { - sender = sender.ToUpper(); - - Log.WriteLine("[" + sender + "] "); - - - Log.Flush(); - - System.Console.Write("["); - - try - { - System.Console.ForegroundColor = color; - System.Console.Write(sender); - System.Console.ResetColor(); - } - catch (ArgumentNullException) - { - // Some older systems dont support coloured text. - System.Console.WriteLine(sender); - } - - System.Console.Write("] \t"); - - return; - } - } - catch (ObjectDisposedException) - { - return; - } - } - - - public string ReadLine() - { - try - { - string TempStr = System.Console.ReadLine(); - Log.WriteLine(TempStr); - return TempStr; - } - catch (Exception e) - { - MainLog.Instance.Error("Console", "System.Console.ReadLine exception " + e.ToString()); - return String.Empty; - } - } - - public int Read() - { - int TempInt = System.Console.Read(); - Log.Write((char) TempInt); - return TempInt; - } - - public IPAddress CmdPromptIPAddress(string prompt, string defaultvalue) - { - IPAddress address; - string addressStr; - - while (true) - { - addressStr = MainLog.Instance.CmdPrompt(prompt, defaultvalue); - if (IPAddress.TryParse(addressStr, out address)) - { - break; - } - else - { - MainLog.Instance.Error("Illegal address. Please re-enter."); - } - } - - return address; - } - - public uint CmdPromptIPPort(string prompt, string defaultvalue) - { - uint port; - string portStr; - - while (true) - { - portStr = MainLog.Instance.CmdPrompt(prompt, defaultvalue); - if (uint.TryParse(portStr, out port)) - { - if (port >= IPEndPoint.MinPort && port <= IPEndPoint.MaxPort) - { - break; - } - } - - MainLog.Instance.Error("Illegal address. Please re-enter."); - } - - return port; - } - - // Displays a prompt and waits for the user to enter a string, then returns that string - // Done with no echo and suitable for passwords - public string PasswdPrompt(string prompt) - { - // FIXME: Needs to be better abstracted - Log.WriteLine(prompt); - Notice(prompt); - ConsoleColor oldfg = System.Console.ForegroundColor; - System.Console.ForegroundColor = System.Console.BackgroundColor; - string temp = System.Console.ReadLine(); - System.Console.ForegroundColor = oldfg; - return temp; - } - - // Displays a command prompt and waits for the user to enter a string, then returns that string - public string CmdPrompt(string prompt) - { - Notice(String.Format("{0}: ", prompt)); - return ReadLine(); - } - - // Displays a command prompt and returns a default value if the user simply presses enter - public string CmdPrompt(string prompt, string defaultresponse) - { - string temp = CmdPrompt(String.Format("{0} [{1}]", prompt, defaultresponse)); - if (temp == String.Empty) - { - return defaultresponse; - } - else - { - return temp; - } - } - - // Displays a command prompt and returns a default value, user may only enter 1 of 2 options - public string CmdPrompt(string prompt, string defaultresponse, string OptionA, string OptionB) - { - bool itisdone = false; - string temp = CmdPrompt(prompt, defaultresponse); - while (itisdone == false) - { - if ((temp == OptionA) || (temp == OptionB)) - { - itisdone = true; - } - else - { - Notice("Valid options are " + OptionA + " or " + OptionB); - temp = CmdPrompt(prompt, defaultresponse); - } - } - return temp; - } - - // Runs a command with a number of parameters - public Object RunCmd(string Cmd, string[] cmdparams) - { - cmdparser.RunCmd(Cmd, cmdparams); - return null; - } - - // Shows data about something - public void ShowCommands(string ShowWhat) - { - cmdparser.Show(ShowWhat); - } - - public void MainLogPrompt() - { - string tempstr = CmdPrompt(componentname + "# "); - MainLogRunCommand(tempstr); - } - - public void MainLogRunCommand(string command) - { - string[] tempstrarray; - tempstrarray = command.Split(' '); - string cmd = tempstrarray[0]; - Array.Reverse(tempstrarray); - Array.Resize(ref tempstrarray, tempstrarray.Length - 1); - Array.Reverse(tempstrarray); - string[] cmdparams = (string[]) tempstrarray; - try - { - RunCmd(cmd, cmdparams); - } - catch (Exception e) - { - MainLog.Instance.Error("Console", "Command failed with exception " + e.ToString()); - } - } - - public string LineInfo - { - get - { - string result = String.Empty; - - string stacktrace = Environment.StackTrace; - List lines = new List(stacktrace.Split(new string[] {"at "}, StringSplitOptions.None)); - - if (lines.Count > 4) - { - lines.RemoveRange(0, 4); - - string tmpLine = lines[0]; - - int inIndex = tmpLine.IndexOf(" in "); - - if (inIndex > -1) - { - result = tmpLine.Substring(0, inIndex); - - int lineIndex = tmpLine.IndexOf(":line "); - - if (lineIndex > -1) - { - lineIndex += 6; - result += ", line " + tmpLine.Substring(lineIndex, (tmpLine.Length - lineIndex) - 5); - } - } - } - return result; - } - } - } -} diff --git a/OpenSim/Framework/Console/MainConsole.cs b/OpenSim/Framework/Console/MainConsole.cs new file mode 100644 index 0000000..fb88d04 --- /dev/null +++ b/OpenSim/Framework/Console/MainConsole.cs @@ -0,0 +1,41 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +namespace OpenSim.Framework.Console +{ + public class MainConsole + { + private static ConsoleBase instance; + + public static ConsoleBase Instance + { + get { return instance; } + set { instance = value; } + } + } +} \ No newline at end of file diff --git a/OpenSim/Framework/Console/MainLog.cs b/OpenSim/Framework/Console/MainLog.cs deleted file mode 100644 index bea2a22..0000000 --- a/OpenSim/Framework/Console/MainLog.cs +++ /dev/null @@ -1,40 +0,0 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -namespace OpenSim.Framework.Console -{ - public class MainLog - { - private static LogBase instance; - - public static LogBase Instance - { - get { return instance; } - set { instance = value; } - } - } -} \ No newline at end of file diff --git a/OpenSim/Framework/Data.DB4o/DB4oUserData.cs b/OpenSim/Framework/Data.DB4o/DB4oUserData.cs index 6059cbe..35a3635 100644 --- a/OpenSim/Framework/Data.DB4o/DB4oUserData.cs +++ b/OpenSim/Framework/Data.DB4o/DB4oUserData.cs @@ -37,6 +37,8 @@ namespace OpenSim.Framework.Data.DB4o /// public class DB4oUserData : IUserData { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + /// /// The database manager /// @@ -143,22 +145,22 @@ namespace OpenSim.Framework.Data.DB4o public void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms) { - //MainLog.Instance.Verbose("FRIEND", "Stub AddNewUserFriend called"); + //m_log.Info("[FRIEND]: Stub AddNewUserFriend called"); } public void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend) { - //MainLog.Instance.Verbose("FRIEND", "Stub RemoveUserFriend called"); + //m_log.Info("[FRIEND]: Stub RemoveUserFriend called"); } public void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms) { - //MainLog.Instance.Verbose("FRIEND", "Stub UpdateUserFriendPerms called"); + //m_log.Info("[FRIEND]: Stub UpdateUserFriendPerms called"); } public List GetUserFriendList(LLUUID friendlistowner) { - //MainLog.Instance.Verbose("FRIEND", "Stub GetUserFriendList called"); + //m_log.Info("[FRIEND]: Stub GetUserFriendList called"); return new List(); } @@ -166,7 +168,7 @@ namespace OpenSim.Framework.Data.DB4o public void UpdateUserCurrentRegion(LLUUID avatarid, LLUUID regionuuid) { - //MainLog.Instance.Verbose("USER", "Stub UpdateUserCUrrentRegion called"); + //m_log.Info("[USER]: Stub UpdateUserCUrrentRegion called"); } diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLAssetData.cs b/OpenSim/Framework/Data.MSSQL/MSSQLAssetData.cs index 08fbef0..4d5e4c7 100644 --- a/OpenSim/Framework/Data.MSSQL/MSSQLAssetData.cs +++ b/OpenSim/Framework/Data.MSSQL/MSSQLAssetData.cs @@ -37,6 +37,8 @@ namespace OpenSim.Framework.Data.MSSQL { internal class MSSQLAssetData : IAssetProvider { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private MSSQLManager database; #region IAssetProvider Members @@ -46,7 +48,7 @@ namespace OpenSim.Framework.Data.MSSQL // null as the version, indicates that the table didn't exist if (tableName == null) { - MainLog.Instance.Notice("ASSETS", "Creating new database tables"); + m_log.Info("[ASSETS]: Creating new database tables"); database.ExecuteResourceSql("CreateAssetsTable.sql"); return; } @@ -164,7 +166,7 @@ namespace OpenSim.Framework.Data.MSSQL } catch (Exception e) { - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); } } diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs b/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs index 7d228e6..28eec3e 100644 --- a/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs +++ b/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs @@ -40,6 +40,8 @@ namespace OpenSim.Framework.Data.MSSQL /// public class SqlGridData : IGridData { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + /// /// Database manager /// @@ -172,7 +174,7 @@ namespace OpenSim.Framework.Data.MSSQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return returnlist; } } @@ -208,7 +210,7 @@ namespace OpenSim.Framework.Data.MSSQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return returnlist; } } diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLInventoryData.cs b/OpenSim/Framework/Data.MSSQL/MSSQLInventoryData.cs index 2e5d679..d79d369 100644 --- a/OpenSim/Framework/Data.MSSQL/MSSQLInventoryData.cs +++ b/OpenSim/Framework/Data.MSSQL/MSSQLInventoryData.cs @@ -39,6 +39,8 @@ namespace OpenSim.Framework.Data.MSSQL /// public class MSSQLInventoryData : IInventoryData { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + /// /// The database manager /// @@ -159,7 +161,7 @@ namespace OpenSim.Framework.Data.MSSQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return null; } } @@ -198,7 +200,7 @@ namespace OpenSim.Framework.Data.MSSQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return null; } } @@ -244,7 +246,7 @@ namespace OpenSim.Framework.Data.MSSQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return null; } } @@ -282,7 +284,7 @@ namespace OpenSim.Framework.Data.MSSQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return null; } } @@ -315,7 +317,7 @@ namespace OpenSim.Framework.Data.MSSQL } catch (SqlException e) { - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); } return null; @@ -352,7 +354,7 @@ namespace OpenSim.Framework.Data.MSSQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); } return null; } @@ -377,7 +379,7 @@ namespace OpenSim.Framework.Data.MSSQL } catch (Exception e) { - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); } return null; @@ -412,7 +414,7 @@ namespace OpenSim.Framework.Data.MSSQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return null; } } @@ -452,7 +454,7 @@ namespace OpenSim.Framework.Data.MSSQL } catch (SqlException e) { - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); } } @@ -511,7 +513,7 @@ namespace OpenSim.Framework.Data.MSSQL } catch (Exception e) { - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); } } @@ -533,7 +535,7 @@ namespace OpenSim.Framework.Data.MSSQL catch (SqlException e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); } } @@ -564,7 +566,7 @@ namespace OpenSim.Framework.Data.MSSQL } catch (Exception e) { - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); } } @@ -602,7 +604,7 @@ namespace OpenSim.Framework.Data.MSSQL } catch (Exception e) { - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); } } @@ -628,7 +630,7 @@ namespace OpenSim.Framework.Data.MSSQL } catch (Exception e) { - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); } } @@ -675,7 +677,7 @@ namespace OpenSim.Framework.Data.MSSQL catch (SqlException e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); } } @@ -695,7 +697,7 @@ namespace OpenSim.Framework.Data.MSSQL catch (SqlException e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); } } diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs b/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs index 3a70909..e54cde1 100644 --- a/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs +++ b/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs @@ -42,6 +42,8 @@ namespace OpenSim.Framework.Data.MSSQL /// internal class MSSQLManager { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + /// /// The database connection object /// @@ -92,7 +94,7 @@ namespace OpenSim.Framework.Data.MSSQL } catch (Exception) { - MainLog.Instance.Verbose("DATASTORE", "MSSQL Database doesn't exist... creating"); + m_log.Info("[DATASTORE]: MSSQL Database doesn't exist... creating"); InitDB(conn); } cmd = Query("select top 1 webLoginKey from users", new Dictionary()); @@ -260,7 +262,7 @@ namespace OpenSim.Framework.Data.MSSQL } catch (Exception e) { - MainLog.Instance.Error("Unable to reconnect to database " + e.ToString()); + m_log.Error("Unable to reconnect to database " + e.ToString()); } } } @@ -529,7 +531,7 @@ namespace OpenSim.Framework.Data.MSSQL } catch (Exception e) { - MainLog.Instance.Error("MSSQLManager : " + e.ToString()); + m_log.Error("MSSQLManager : " + e.ToString()); } return returnval; @@ -573,7 +575,7 @@ namespace OpenSim.Framework.Data.MSSQL } catch (Exception e) { - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return false; } @@ -667,7 +669,7 @@ namespace OpenSim.Framework.Data.MSSQL } catch (Exception e) { - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return false; } @@ -688,7 +690,7 @@ namespace OpenSim.Framework.Data.MSSQL } catch (Exception e) { - MainLog.Instance.Error("Unable to execute query " + e.ToString()); + m_log.Error("Unable to execute query " + e.ToString()); } } @@ -721,7 +723,7 @@ namespace OpenSim.Framework.Data.MSSQL } catch (Exception e) { - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); } } tables.Close(); diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs b/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs index aa0526c..ed9929c 100644 --- a/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs +++ b/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs @@ -39,6 +39,8 @@ namespace OpenSim.Framework.Data.MSSQL /// internal class MSSQLUserData : IUserData { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + /// /// Database manager for MySQL /// @@ -94,7 +96,7 @@ namespace OpenSim.Framework.Data.MSSQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return null; } } @@ -103,22 +105,22 @@ namespace OpenSim.Framework.Data.MSSQL public void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms) { - MainLog.Instance.Verbose("FRIEND", "Stub AddNewUserFriend called"); + m_log.Info("[FRIEND]: Stub AddNewUserFriend called"); } public void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend) { - MainLog.Instance.Verbose("FRIEND", "Stub RemoveUserFriend called"); + m_log.Info("[FRIEND]: Stub RemoveUserFriend called"); } public void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms) { - MainLog.Instance.Verbose("FRIEND", "Stub UpdateUserFriendPerms called"); + m_log.Info("[FRIEND]: Stub UpdateUserFriendPerms called"); } public List GetUserFriendList(LLUUID friendlistowner) { - MainLog.Instance.Verbose("FRIEND", "Stub GetUserFriendList called"); + m_log.Info("[FRIEND]: Stub GetUserFriendList called"); return new List(); } @@ -126,7 +128,7 @@ namespace OpenSim.Framework.Data.MSSQL public void UpdateUserCurrentRegion(LLUUID avatarid, LLUUID regionuuid) { - MainLog.Instance.Verbose("USER", "Stub UpdateUserCUrrentRegion called"); + m_log.Info("[USER]: Stub UpdateUserCUrrentRegion called"); } @@ -168,7 +170,7 @@ namespace OpenSim.Framework.Data.MSSQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return returnlist; } } @@ -204,7 +206,7 @@ namespace OpenSim.Framework.Data.MSSQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return returnlist; } } @@ -235,7 +237,7 @@ namespace OpenSim.Framework.Data.MSSQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return null; } } @@ -290,7 +292,7 @@ namespace OpenSim.Framework.Data.MSSQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return null; } } @@ -324,7 +326,7 @@ namespace OpenSim.Framework.Data.MSSQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); } } @@ -426,7 +428,7 @@ namespace OpenSim.Framework.Data.MSSQL } catch (Exception e) { - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); } return false; } diff --git a/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs b/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs index 407d6d2..f9ef699 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs @@ -37,6 +37,8 @@ namespace OpenSim.Framework.Data.MySQL { internal class MySQLAssetData : IAssetProvider { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private MySQLManager _dbConnection; #region IAssetProvider Members @@ -46,7 +48,7 @@ namespace OpenSim.Framework.Data.MySQL // null as the version, indicates that the table didn't exist if (oldVersion == null) { - MainLog.Instance.Notice("ASSETS", "Creating new database tables"); + m_log.Info("[ASSETS]: Creating new database tables"); _dbConnection.ExecuteResourceSql("CreateAssetsTable.sql"); return; } @@ -98,9 +100,9 @@ namespace OpenSim.Framework.Data.MySQL } catch (Exception e) { - MainLog.Instance.Error( - "ASSETS", "MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() - + Environment.NewLine + "Attempting reconnection", assetID); + m_log.Error(String.Format( + "[ASSETS]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() + + Environment.NewLine + "Attempting reconnection", assetID)); _dbConnection.Reconnect(); } } @@ -137,10 +139,10 @@ namespace OpenSim.Framework.Data.MySQL } catch (Exception e) { - MainLog.Instance.Error( - "ASSETS", - "MySql failure creating asset {0} with name {1}" + Environment.NewLine + e.ToString() - + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name); + m_log.Error(String.Format( + "[ASSETS]: " + + "MySql failure creating asset {0} with name {1}" + Environment.NewLine + e.ToString() + + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name)); _dbConnection.Reconnect(); } } diff --git a/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs b/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs index 54f39bb..e2ea018 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs @@ -42,6 +42,8 @@ namespace OpenSim.Framework.Data.MySQL { public class MySQLDataStore : IRegionDataStore { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private const string m_primSelect = "select * from prims"; private const string m_shapeSelect = "select * from primshapes"; private const string m_itemsSelect = "select * from primitems"; @@ -80,7 +82,7 @@ namespace OpenSim.Framework.Data.MySQL m_dataSet = new DataSet(); this.persistPrimInventories = persistPrimInventories; - MainLog.Instance.Verbose("DATASTORE", "MySql - connecting: " + connectionstring); + m_log.Info("[DATASTORE]: MySql - connecting: " + connectionstring); m_connection = new MySqlConnection(connectionstring); MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, m_connection); @@ -148,12 +150,12 @@ namespace OpenSim.Framework.Data.MySQL { if ((prim.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) == 0) { - MainLog.Instance.Verbose("DATASTORE", "Adding obj: " + obj.UUID + " to region: " + regionUUID); + m_log.Info("[DATASTORE]: Adding obj: " + obj.UUID + " to region: " + regionUUID); addPrim(prim, obj.UUID, regionUUID); } else { - // MainLog.Instance.Verbose("DATASTORE", "Ignoring Physical obj: " + obj.UUID + " in region: " + regionUUID); + // m_log.Info("[DATASTORE]: Ignoring Physical obj: " + obj.UUID + " in region: " + regionUUID); } } } @@ -163,7 +165,7 @@ namespace OpenSim.Framework.Data.MySQL public void RemoveObject(LLUUID obj, LLUUID regionUUID) { - MainLog.Instance.Verbose("DATASTORE", "Removing obj: {0} from region: {1}", obj.UUID, regionUUID); + m_log.Info(String.Format("[DATASTORE]: Removing obj: {0} from region: {1}", obj.UUID, regionUUID)); DataTable prims = m_primTable; DataTable shapes = m_shapeTable; @@ -228,7 +230,7 @@ namespace OpenSim.Framework.Data.MySQL lock (m_dataSet) { DataRow[] primsForRegion = prims.Select(byRegion, orderByParent); - MainLog.Instance.Verbose("DATASTORE", + m_log.Info("[DATASTORE]: " + "Loaded " + primsForRegion.Length + " prims for region: " + regionUUID); foreach (DataRow primRow in primsForRegion) @@ -251,7 +253,7 @@ namespace OpenSim.Framework.Data.MySQL } else { - MainLog.Instance.Notice( + m_log.Info( "No shape found for prim in storage, so setting default box shape"); prim.Shape = PrimitiveBaseShape.Default; } @@ -270,7 +272,7 @@ namespace OpenSim.Framework.Data.MySQL } else { - MainLog.Instance.Notice( + m_log.Info( "No shape found for prim in storage, so setting default box shape"); prim.Shape = PrimitiveBaseShape.Default; } @@ -284,11 +286,11 @@ namespace OpenSim.Framework.Data.MySQL } catch (Exception e) { - MainLog.Instance.Error("DATASTORE", "Failed create prim object, exception and data follows"); - MainLog.Instance.Verbose("DATASTORE", e.ToString()); + m_log.Error("[DATASTORE]: Failed create prim object, exception and data follows"); + m_log.Info("[DATASTORE]: " + e.ToString()); foreach (DataColumn col in prims.Columns) { - MainLog.Instance.Verbose("DATASTORE", "Col: " + col.ColumnName + " => " + primRow[col]); + m_log.Info("[DATASTORE]: Col: " + col.ColumnName + " => " + primRow[col]); } } } @@ -302,7 +304,7 @@ namespace OpenSim.Framework.Data.MySQL /// private void LoadItems(SceneObjectPart prim) { - //MainLog.Instance.Verbose("DATASTORE", "Loading inventory for {0}, {1}", prim.Name, prim.UUID); + //m_log.Info(String.Format("[DATASTORE]: Loading inventory for {0}, {1}", prim.Name, prim.UUID)); DataTable dbItems = m_itemsTable; @@ -316,7 +318,7 @@ namespace OpenSim.Framework.Data.MySQL TaskInventoryItem item = buildItem(row); inventory.Add(item); - MainLog.Instance.Verbose("DATASTORE", "Restored item {0}, {1}", item.Name, item.ItemID); + m_log.Info(String.Format("[DATASTORE]: Restored item {0}, {1}", item.Name, item.ItemID)); } prim.RestoreInventoryItems(inventory); @@ -332,7 +334,7 @@ namespace OpenSim.Framework.Data.MySQL public void StoreTerrain(double[,] ter, LLUUID regionID) { int revision = Util.UnixTimeSinceEpoch(); - MainLog.Instance.Verbose("DATASTORE", "Storing terrain revision r" + revision.ToString()); + m_log.Info("[DATASTORE]: Storing terrain revision r" + revision.ToString()); DataTable terrain = m_dataSet.Tables["terrain"]; lock (m_dataSet) @@ -384,11 +386,11 @@ namespace OpenSim.Framework.Data.MySQL } else { - MainLog.Instance.Verbose("DATASTORE", "No terrain found for region"); + m_log.Info("[DATASTORE]: No terrain found for region"); return null; } - MainLog.Instance.Verbose("DATASTORE", "Loaded terrain revision r" + rev.ToString()); + m_log.Info("[DATASTORE]: Loaded terrain revision r" + rev.ToString()); } return terret; @@ -418,7 +420,7 @@ namespace OpenSim.Framework.Data.MySQL public void StoreLandObject(Land parcel, LLUUID regionUUID) { // Does the new locking fix it? - MainLog.Instance.Verbose("DATASTORE", "Tedds temp fix: Waiting 3 seconds for stuff to catch up. (Someone please fix! :))"); + m_log.Info("[DATASTORE]: Tedds temp fix: Waiting 3 seconds for stuff to catch up. (Someone please fix! :))"); System.Threading.Thread.Sleep(2500 + rnd.Next(300, 900)); lock (m_dataSet) @@ -1214,7 +1216,7 @@ namespace OpenSim.Framework.Data.MySQL if (!persistPrimInventories) return; - MainLog.Instance.Verbose("DATASTORE", "Persisting Prim Inventory with prim ID {0}", primID); + m_log.Info(String.Format("[DATASTORE]: Persisting Prim Inventory with prim ID {0}", primID)); // For now, we're just going to crudely remove all the previous inventory items // no matter whether they have changed or not, and replace them with the current set. @@ -1225,10 +1227,10 @@ namespace OpenSim.Framework.Data.MySQL // repalce with current inventory details foreach (TaskInventoryItem newItem in items) { -// MainLog.Instance.Verbose( -// "DATASTORE", -// "Adding item {0}, {1} to prim ID {2}", -// newItem.Name, newItem.ItemID, newItem.ParentPartID); +// m_log.Info(String.Format( +// "[DATASTORE]: " + +// "Adding item {0}, {1} to prim ID {2}", +// newItem.Name, newItem.ItemID, newItem.ParentPartID)); DataRow newItemRow = m_itemsTable.NewRow(); fillItemRow(newItemRow, newItem); @@ -1332,7 +1334,7 @@ namespace OpenSim.Framework.Data.MySQL sql += subsql; sql += ")"; - //MainLog.Instance.Verbose("DATASTORE", "defineTable() sql {0}", sql); + //m_log.Info(String.Format("[DATASTORE]: defineTable() sql {0}", sql)); return sql; } @@ -1463,8 +1465,8 @@ namespace OpenSim.Framework.Data.MySQL } catch (Exception ex) { - MainLog.Instance.Error("MySql", "Error connecting to MySQL server: " + ex.Message); - MainLog.Instance.Error("MySql", "Application is terminating!"); + m_log.Error("[MySql]: Error connecting to MySQL server: " + ex.Message); + m_log.Error("[MySql]: Application is terminating!"); System.Threading.Thread.CurrentThread.Abort(); } } @@ -1475,7 +1477,7 @@ namespace OpenSim.Framework.Data.MySQL } catch (MySqlException e) { - MainLog.Instance.Warn("MySql", "Primitives Table Already Exists: {0}", e); + m_log.Warn(String.Format("[MySql]: Primitives Table Already Exists: {0}", e)); } try @@ -1484,7 +1486,7 @@ namespace OpenSim.Framework.Data.MySQL } catch (MySqlException e) { - MainLog.Instance.Warn("MySql", "Shapes Table Already Exists: {0}", e); + m_log.Warn(String.Format("[MySql]: Shapes Table Already Exists: {0}", e)); } try @@ -1493,7 +1495,7 @@ namespace OpenSim.Framework.Data.MySQL } catch (MySqlException e) { - MainLog.Instance.Warn("MySql", "Items Table Already Exists: {0}", e); + m_log.Warn(String.Format("[MySql]: Items Table Already Exists: {0}", e)); } try @@ -1502,7 +1504,7 @@ namespace OpenSim.Framework.Data.MySQL } catch (MySqlException e) { - MainLog.Instance.Warn("MySql", "Terrain Table Already Exists: {0}", e); + m_log.Warn(String.Format("[MySql]: Terrain Table Already Exists: {0}", e)); } try @@ -1511,7 +1513,7 @@ namespace OpenSim.Framework.Data.MySQL } catch (MySqlException e) { - MainLog.Instance.Warn("MySql", "Land Table Already Exists: {0}", e); + m_log.Warn(String.Format("[MySql]: Land Table Already Exists: {0}", e)); } try @@ -1520,7 +1522,7 @@ namespace OpenSim.Framework.Data.MySQL } catch (MySqlException e) { - MainLog.Instance.Warn("MySql", "LandAccessList Table Already Exists: {0}", e); + m_log.Warn(String.Format("[MySql]: LandAccessList Table Already Exists: {0}", e)); } conn.Close(); } @@ -1555,7 +1557,7 @@ namespace OpenSim.Framework.Data.MySQL } catch (MySqlException) { - MainLog.Instance.Verbose("DATASTORE", "MySql Database doesn't exist... creating"); + m_log.Info("[DATASTORE]: MySql Database doesn't exist... creating"); InitDB(conn); } @@ -1573,7 +1575,7 @@ namespace OpenSim.Framework.Data.MySQL { if (!tmpDS.Tables["prims"].Columns.Contains(col.ColumnName)) { - MainLog.Instance.Verbose("DATASTORE", "Missing required column:" + col.ColumnName); + m_log.Info("[DATASTORE]: Missing required column:" + col.ColumnName); return false; } } @@ -1582,7 +1584,7 @@ namespace OpenSim.Framework.Data.MySQL { if (!tmpDS.Tables["primshapes"].Columns.Contains(col.ColumnName)) { - MainLog.Instance.Verbose("DATASTORE", "Missing required column:" + col.ColumnName); + m_log.Info("[DATASTORE]: Missing required column:" + col.ColumnName); return false; } } @@ -1593,7 +1595,7 @@ namespace OpenSim.Framework.Data.MySQL { if (!tmpDS.Tables["terrain"].Columns.Contains(col.ColumnName)) { - MainLog.Instance.Verbose("DATASTORE", "Missing require column:" + col.ColumnName); + m_log.Info("[DATASTORE]: Missing require column:" + col.ColumnName); return false; } } @@ -1602,7 +1604,7 @@ namespace OpenSim.Framework.Data.MySQL { if (!tmpDS.Tables["land"].Columns.Contains(col.ColumnName)) { - MainLog.Instance.Verbose("DATASTORE", "Missing require column:" + col.ColumnName); + m_log.Info("[DATASTORE]: Missing require column:" + col.ColumnName); return false; } } @@ -1611,7 +1613,7 @@ namespace OpenSim.Framework.Data.MySQL { if (!tmpDS.Tables["landaccesslist"].Columns.Contains(col.ColumnName)) { - MainLog.Instance.Verbose("DATASTORE", "Missing require column:" + col.ColumnName); + m_log.Info("[DATASTORE]: Missing require column:" + col.ColumnName); return false; } } diff --git a/OpenSim/Framework/Data.MySQL/MySQLGridData.cs b/OpenSim/Framework/Data.MySQL/MySQLGridData.cs index c8c4ab0..d62c286 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLGridData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLGridData.cs @@ -42,6 +42,8 @@ namespace OpenSim.Framework.Data.MySQL /// public class MySQLGridData : IGridData { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + /// /// MySQL Database Manager /// @@ -168,7 +170,7 @@ namespace OpenSim.Framework.Data.MySQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return null; } } @@ -200,7 +202,7 @@ namespace OpenSim.Framework.Data.MySQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return null; } } @@ -247,7 +249,7 @@ namespace OpenSim.Framework.Data.MySQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return returnlist; } } @@ -282,7 +284,7 @@ namespace OpenSim.Framework.Data.MySQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return returnlist; } } @@ -316,7 +318,7 @@ namespace OpenSim.Framework.Data.MySQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return null; } } @@ -405,7 +407,7 @@ namespace OpenSim.Framework.Data.MySQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return null; } } diff --git a/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs b/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs index c317f4a..57c2c9f 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs @@ -38,6 +38,8 @@ namespace OpenSim.Framework.Data.MySQL /// public class MySQLInventoryData : IInventoryData { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + /// /// The database manager /// @@ -104,8 +106,8 @@ namespace OpenSim.Framework.Data.MySQL tableList["inventoryitems"] = null; database.GetTableVersion(tableList); - MainLog.Instance.Verbose("MYSQL", "Inventory Folder Version: " + tableList["inventoryfolders"]); - MainLog.Instance.Verbose("MYSQL", "Inventory Items Version: " + tableList["inventoryitems"]); + m_log.Info("[MYSQL]: Inventory Folder Version: " + tableList["inventoryfolders"]); + m_log.Info("[MYSQL]: Inventory Items Version: " + tableList["inventoryitems"]); UpgradeFoldersTable(tableList["inventoryfolders"]); UpgradeItemsTable(tableList["inventoryitems"]); @@ -170,7 +172,7 @@ namespace OpenSim.Framework.Data.MySQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return null; } } @@ -208,7 +210,7 @@ namespace OpenSim.Framework.Data.MySQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return null; } } @@ -254,7 +256,7 @@ namespace OpenSim.Framework.Data.MySQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return null; } } @@ -292,7 +294,7 @@ namespace OpenSim.Framework.Data.MySQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return null; } } @@ -325,7 +327,7 @@ namespace OpenSim.Framework.Data.MySQL } catch (MySqlException e) { - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); } return null; @@ -362,7 +364,7 @@ namespace OpenSim.Framework.Data.MySQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); } return null; } @@ -387,7 +389,7 @@ namespace OpenSim.Framework.Data.MySQL } catch (Exception e) { - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); } return null; @@ -421,7 +423,7 @@ namespace OpenSim.Framework.Data.MySQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return null; } } @@ -459,7 +461,7 @@ namespace OpenSim.Framework.Data.MySQL } catch (MySqlException e) { - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); } } @@ -488,7 +490,7 @@ namespace OpenSim.Framework.Data.MySQL catch (MySqlException e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); } } @@ -516,7 +518,7 @@ namespace OpenSim.Framework.Data.MySQL } catch (Exception e) { - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); } } @@ -548,7 +550,7 @@ namespace OpenSim.Framework.Data.MySQL } catch (Exception e) { - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); } } @@ -593,7 +595,7 @@ namespace OpenSim.Framework.Data.MySQL catch (MySqlException e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); } } @@ -609,7 +611,7 @@ namespace OpenSim.Framework.Data.MySQL catch (MySqlException e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); } } diff --git a/OpenSim/Framework/Data.MySQL/MySQLManager.cs b/OpenSim/Framework/Data.MySQL/MySQLManager.cs index 3df0242..f70b505 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLManager.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLManager.cs @@ -42,6 +42,8 @@ namespace OpenSim.Framework.Data.MySQL /// internal class MySQLManager { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + /// /// The database connection object /// @@ -71,7 +73,7 @@ namespace OpenSim.Framework.Data.MySQL dbcon.Open(); - MainLog.Instance.Verbose("MYSQL", "Connection established"); + m_log.Info("[MYSQL]: Connection established"); } catch (Exception e) { @@ -113,7 +115,7 @@ namespace OpenSim.Framework.Data.MySQL } catch (Exception e) { - MainLog.Instance.Error("Unable to reconnect to database " + e.ToString()); + m_log.Error("Unable to reconnect to database " + e.ToString()); } } } @@ -194,7 +196,7 @@ namespace OpenSim.Framework.Data.MySQL } catch (Exception e) { - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); } } tables.Close(); @@ -245,7 +247,7 @@ namespace OpenSim.Framework.Data.MySQL } catch (Exception e) { - MainLog.Instance.Error("Unable to reconnect to database " + e.ToString()); + m_log.Error("Unable to reconnect to database " + e.ToString()); } // Run the query again @@ -263,7 +265,7 @@ namespace OpenSim.Framework.Data.MySQL catch (Exception e) { // Return null if it fails. - MainLog.Instance.Error("Failed during Query generation: " + e.ToString()); + m_log.Error("Failed during Query generation: " + e.ToString()); return null; } } @@ -523,7 +525,7 @@ namespace OpenSim.Framework.Data.MySQL } catch (Exception e) { - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return false; } @@ -617,7 +619,7 @@ namespace OpenSim.Framework.Data.MySQL } catch (Exception e) { - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return false; } @@ -726,7 +728,7 @@ namespace OpenSim.Framework.Data.MySQL } catch (Exception e) { - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return false; } diff --git a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs index 2ee20e0..0db727c 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs @@ -39,6 +39,8 @@ namespace OpenSim.Framework.Data.MySQL /// internal class MySQLUserData : IUserData { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + /// /// Database manager for MySQL /// @@ -119,7 +121,7 @@ namespace OpenSim.Framework.Data.MySQL database.ExecuteResourceSql("UpgradeUsersTableToVersion2.sql"); return; } - //MainLog.Instance.Verbose("DB","DBVers:" + oldVersion); + //m_log.Info("[DB]: DBVers:" + oldVersion); } /// @@ -164,7 +166,7 @@ namespace OpenSim.Framework.Data.MySQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return null; } } @@ -208,7 +210,7 @@ namespace OpenSim.Framework.Data.MySQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return; } } @@ -243,7 +245,7 @@ namespace OpenSim.Framework.Data.MySQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return; } } @@ -272,7 +274,7 @@ namespace OpenSim.Framework.Data.MySQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return; } } @@ -317,7 +319,7 @@ namespace OpenSim.Framework.Data.MySQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return Lfli; } @@ -328,7 +330,7 @@ namespace OpenSim.Framework.Data.MySQL public void UpdateUserCurrentRegion(LLUUID avatarid, LLUUID regionuuid) { - MainLog.Instance.Verbose("USER", "Stub UpdateUserCUrrentRegion called"); + m_log.Info("[USER]: Stub UpdateUserCUrrentRegion called"); } @@ -371,7 +373,7 @@ namespace OpenSim.Framework.Data.MySQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return returnlist; } } @@ -406,7 +408,7 @@ namespace OpenSim.Framework.Data.MySQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return returnlist; } } @@ -437,7 +439,7 @@ namespace OpenSim.Framework.Data.MySQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return null; } } @@ -488,7 +490,7 @@ namespace OpenSim.Framework.Data.MySQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return; } @@ -525,7 +527,7 @@ namespace OpenSim.Framework.Data.MySQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); return null; } } @@ -553,7 +555,7 @@ namespace OpenSim.Framework.Data.MySQL catch (Exception e) { database.Reconnect(); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); } } diff --git a/OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs b/OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs index 76608c7..d08ef8b 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs @@ -39,6 +39,8 @@ namespace OpenSim.Framework.Data.SQLite /// public class SQLiteAssetData : SQLiteBase, IAssetProvider { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + /// /// The database manager /// @@ -86,10 +88,10 @@ namespace OpenSim.Framework.Data.SQLite public void CreateAsset(AssetBase asset) { - MainLog.Instance.Verbose("SQLITE", "Creating Asset " + Util.ToRawUuidString(asset.FullID)); + m_log.Info("[SQLITE]: Creating Asset " + Util.ToRawUuidString(asset.FullID)); if (ExistsAsset(asset.FullID)) { - MainLog.Instance.Verbose("SQLITE", "Asset exists, updating instead. You should fix the caller for this!"); + m_log.Info("[SQLITE]: Asset exists, updating instead. You should fix the caller for this!"); UpdateAsset(asset); } else @@ -135,7 +137,7 @@ namespace OpenSim.Framework.Data.SQLite string temporary = asset.Temporary ? "Temporary" : "Stored"; string local = asset.Local ? "Local" : "Remote"; - MainLog.Instance.Verbose("SQLITE", + m_log.Info("[SQLITE]: " + string.Format("Loaded {6} {5} Asset: [{0}][{3}/{4}] \"{1}\":{2} ({7} bytes)", asset.FullID, asset.Name, asset.Description, asset.Type, asset.InvType, temporary, local, asset.Data.Length)); @@ -174,7 +176,7 @@ namespace OpenSim.Framework.Data.SQLite public void CommitAssets() // force a sync to the database { - MainLog.Instance.Verbose("SQLITE", "Attempting commit"); + m_log.Info("[SQLITE]: Attempting commit"); // lock (ds) // { // da.Update(ds, "assets"); @@ -261,7 +263,7 @@ namespace OpenSim.Framework.Data.SQLite } catch (SqliteSyntaxException) { - MainLog.Instance.Verbose("SQLITE", "SQLite Database doesn't exist... creating"); + m_log.Info("[SQLITE]: SQLite Database doesn't exist... creating"); InitDB(conn); } return true; diff --git a/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs b/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs index 64a27f0..5e5d1e4 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs @@ -38,6 +38,8 @@ namespace OpenSim.Framework.Data.SQLite { public class SQLiteInventoryStore : SQLiteBase, IInventoryData { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private const string invItemsSelect = "select * from inventoryitems"; private const string invFoldersSelect = "select * from inventoryfolders"; @@ -57,7 +59,7 @@ namespace OpenSim.Framework.Data.SQLite { string connectionString = "URI=file:" + dbfile + ",version=3"; - MainLog.Instance.Verbose("Inventory", "Sqlite - connecting: " + dbfile); + m_log.Info("[Inventory]: Sqlite - connecting: " + dbfile); SqliteConnection conn = new SqliteConnection(connectionString); TestTables(conn); @@ -74,12 +76,12 @@ namespace OpenSim.Framework.Data.SQLite ds.Tables.Add(createInventoryFoldersTable()); invFoldersDa.Fill(ds.Tables["inventoryfolders"]); setupFoldersCommands(invFoldersDa, conn); - MainLog.Instance.Verbose("DATASTORE", "Populated Intentory Folders Definitions"); + m_log.Info("[DATASTORE]: Populated Intentory Folders Definitions"); ds.Tables.Add(createInventoryItemsTable()); invItemsDa.Fill(ds.Tables["inventoryitems"]); setupItemsCommands(invItemsDa, conn); - MainLog.Instance.Verbose("DATASTORE", "Populated Intentory Items Definitions"); + m_log.Info("[DATASTORE]: Populated Intentory Items Definitions"); ds.AcceptChanges(); } @@ -603,7 +605,7 @@ namespace OpenSim.Framework.Data.SQLite } catch (SqliteSyntaxException) { - MainLog.Instance.Verbose("DATASTORE", "SQLite Database doesn't exist... creating"); + m_log.Info("[DATASTORE]: SQLite Database doesn't exist... creating"); InitDB(conn); } @@ -614,7 +616,7 @@ namespace OpenSim.Framework.Data.SQLite { if (! tmpDS.Tables["inventoryitems"].Columns.Contains(col.ColumnName)) { - MainLog.Instance.Verbose("DATASTORE", "Missing required column:" + col.ColumnName); + m_log.Info("[DATASTORE]: Missing required column:" + col.ColumnName); return false; } } @@ -622,7 +624,7 @@ namespace OpenSim.Framework.Data.SQLite { if (! tmpDS.Tables["inventoryfolders"].Columns.Contains(col.ColumnName)) { - MainLog.Instance.Verbose("DATASTORE", "Missing required column:" + col.ColumnName); + m_log.Info("[DATASTORE]: Missing required column:" + col.ColumnName); return false; } } diff --git a/OpenSim/Framework/Data.SQLite/SQLiteManager.cs b/OpenSim/Framework/Data.SQLite/SQLiteManager.cs index a97b146..c77a8f6 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteManager.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteManager.cs @@ -37,6 +37,8 @@ namespace OpenSim.Framework.Data.SQLite { internal class SQLiteManager : SQLiteBase { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private IDbConnection dbcon; /// @@ -101,7 +103,7 @@ namespace OpenSim.Framework.Data.SQLite } catch (SqliteSyntaxException) { - MainLog.Instance.Verbose("DATASTORE", "SQLite Database doesn't exist... creating"); + m_log.Info("[DATASTORE]: SQLite Database doesn't exist... creating"); InitDB(conn); } return true; diff --git a/OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs b/OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs index 0afc0ce..69dc3f5 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs @@ -42,6 +42,8 @@ namespace OpenSim.Framework.Data.SQLite { public class SQLiteRegionData : IRegionDataStore { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private const string primSelect = "select * from prims"; private const string shapeSelect = "select * from primshapes"; private const string itemsSelect = "select * from primitems"; @@ -78,7 +80,7 @@ namespace OpenSim.Framework.Data.SQLite ds = new DataSet(); - MainLog.Instance.Verbose("DATASTORE", "Sqlite - connecting: " + connectionString); + m_log.Info("[DATASTORE]: Sqlite - connecting: " + connectionString); m_conn = new SqliteConnection(m_connectionString); m_conn.Open(); @@ -142,7 +144,7 @@ namespace OpenSim.Framework.Data.SQLite } catch (Exception) { - MainLog.Instance.Verbose("DATASTORE", "Caught fill error on primshapes table"); + m_log.Info("[DATASTORE]: Caught fill error on primshapes table"); } try @@ -151,7 +153,7 @@ namespace OpenSim.Framework.Data.SQLite } catch (Exception) { - MainLog.Instance.Verbose("DATASTORE", "Caught fill error on terrain table"); + m_log.Info("[DATASTORE]: Caught fill error on terrain table"); } try @@ -160,7 +162,7 @@ namespace OpenSim.Framework.Data.SQLite } catch (Exception) { - MainLog.Instance.Verbose("DATASTORE", "Caught fill error on land table"); + m_log.Info("[DATASTORE]: Caught fill error on land table"); } try @@ -169,7 +171,7 @@ namespace OpenSim.Framework.Data.SQLite } catch (Exception) { - MainLog.Instance.Verbose("DATASTORE", "Caught fill error on landaccesslist table"); + m_log.Info("[DATASTORE]: Caught fill error on landaccesslist table"); } return; } @@ -183,29 +185,29 @@ namespace OpenSim.Framework.Data.SQLite { if ((prim.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) == 0) { - MainLog.Instance.Verbose("DATASTORE", "Adding obj: " + obj.UUID + " to region: " + regionUUID); + m_log.Info("[DATASTORE]: Adding obj: " + obj.UUID + " to region: " + regionUUID); addPrim(prim, Util.ToRawUuidString(obj.UUID), Util.ToRawUuidString(regionUUID)); } else if (prim.Stopped) { - //MainLog.Instance.Verbose("DATASTORE", + //m_log.Info("[DATASTORE]: " + //"Adding stopped obj: " + obj.UUID + " to region: " + regionUUID); //addPrim(prim, Util.ToRawUuidString(obj.UUID), Util.ToRawUuidString(regionUUID)); } else { - // MainLog.Instance.Verbose("DATASTORE", "Ignoring Physical obj: " + obj.UUID + " in region: " + regionUUID); + // m_log.Info("[DATASTORE]: Ignoring Physical obj: " + obj.UUID + " in region: " + regionUUID); } } } Commit(); - // MainLog.Instance.Verbose("Dump of prims:", ds.GetXml()); + // m_log.Info("[Dump of prims]: " + ds.GetXml()); } public void RemoveObject(LLUUID obj, LLUUID regionUUID) { - MainLog.Instance.Verbose("DATASTORE", "Removing obj: {0} from region: {1}", obj.UUID, regionUUID); + m_log.Info(String.Format("[DATASTORE]: Removing obj: {0} from region: {1}", obj.UUID, regionUUID)); DataTable prims = ds.Tables["prims"]; DataTable shapes = ds.Tables["primshapes"]; @@ -274,7 +276,7 @@ namespace OpenSim.Framework.Data.SQLite lock (ds) { DataRow[] primsForRegion = prims.Select(byRegion, orderByParent); - MainLog.Instance.Verbose("DATASTORE", + m_log.Info("[DATASTORE]: " + "Loaded " + primsForRegion.Length + " prims for region: " + regionUUID); foreach (DataRow primRow in primsForRegion) @@ -296,7 +298,7 @@ namespace OpenSim.Framework.Data.SQLite } else { - MainLog.Instance.Notice( + m_log.Info( "No shape found for prim in storage, so setting default box shape"); prim.Shape = PrimitiveBaseShape.Default; } @@ -316,7 +318,7 @@ namespace OpenSim.Framework.Data.SQLite } else { - MainLog.Instance.Notice( + m_log.Info( "No shape found for prim in storage, so setting default box shape"); prim.Shape = PrimitiveBaseShape.Default; } @@ -330,11 +332,11 @@ namespace OpenSim.Framework.Data.SQLite } catch (Exception e) { - MainLog.Instance.Error("DATASTORE", "Failed create prim object, exception and data follows"); - MainLog.Instance.Verbose("DATASTORE", e.ToString()); + m_log.Error("[DATASTORE]: Failed create prim object, exception and data follows"); + m_log.Info("[DATASTORE]: " + e.ToString()); foreach (DataColumn col in prims.Columns) { - MainLog.Instance.Verbose("DATASTORE", "Col: " + col.ColumnName + " => " + primRow[col]); + m_log.Info("[DATASTORE]: Col: " + col.ColumnName + " => " + primRow[col]); } } } @@ -348,7 +350,7 @@ namespace OpenSim.Framework.Data.SQLite /// private void LoadItems(SceneObjectPart prim) { - MainLog.Instance.Verbose("DATASTORE", "Loading inventory for {0}, {1}", prim.Name, prim.UUID); + m_log.Info(String.Format("[DATASTORE]: Loading inventory for {0}, {1}", prim.Name, prim.UUID)); DataTable dbItems = ds.Tables["primitems"]; @@ -362,7 +364,7 @@ namespace OpenSim.Framework.Data.SQLite TaskInventoryItem item = buildItem(row); inventory.Add(item); - MainLog.Instance.Verbose("DATASTORE", "Restored item {0}, {1}", item.Name, item.ItemID); + m_log.Info(String.Format("[DATASTORE]: Restored item {0}, {1}", item.Name, item.ItemID)); } prim.RestoreInventoryItems(inventory); @@ -383,7 +385,7 @@ namespace OpenSim.Framework.Data.SQLite // the following is an work around for .NET. The perf // issues associated with it aren't as bad as you think. - MainLog.Instance.Verbose("DATASTORE", "Storing terrain revision r" + revision.ToString()); + m_log.Info("[DATASTORE]: Storing terrain revision r" + revision.ToString()); String sql = "insert into terrain(RegionUUID, Revision, Heightfield)" + " values(:RegionUUID, :Revision, :Heightfield)"; @@ -446,11 +448,11 @@ namespace OpenSim.Framework.Data.SQLite } else { - MainLog.Instance.Verbose("DATASTORE", "No terrain found for region"); + m_log.Info("[DATASTORE]: No terrain found for region"); return null; } - MainLog.Instance.Verbose("DATASTORE", "Loaded terrain revision r" + rev.ToString()); + m_log.Info("[DATASTORE]: Loaded terrain revision r" + rev.ToString()); } } return terret; @@ -1265,7 +1267,7 @@ namespace OpenSim.Framework.Data.SQLite if (!persistPrimInventories) return; - MainLog.Instance.Verbose("DATASTORE", "Entered StorePrimInventory with prim ID {0}", primID); + m_log.Info(String.Format("[DATASTORE]: Entered StorePrimInventory with prim ID {0}", primID)); DataTable dbItems = ds.Tables["primitems"]; @@ -1278,10 +1280,10 @@ namespace OpenSim.Framework.Data.SQLite // repalce with current inventory details foreach (TaskInventoryItem newItem in items) { -// MainLog.Instance.Verbose( -// "DATASTORE", -// "Adding item {0}, {1} to prim ID {2}", -// newItem.Name, newItem.ItemID, newItem.ParentPartID); +// m_log.Info(String.Format( +// "[DATASTORE]: ", +// "Adding item {0}, {1} to prim ID {2}", +// newItem.Name, newItem.ItemID, newItem.ParentPartID)); DataRow newItemRow = dbItems.NewRow(); fillItemRow(newItemRow, newItem); @@ -1508,7 +1510,7 @@ namespace OpenSim.Framework.Data.SQLite } catch (SqliteSyntaxException) { - MainLog.Instance.Warn("SQLITE", "Primitives Table Already Exists"); + m_log.Warn("[SQLITE]: Primitives Table Already Exists"); } try @@ -1517,7 +1519,7 @@ namespace OpenSim.Framework.Data.SQLite } catch (SqliteSyntaxException) { - MainLog.Instance.Warn("SQLITE", "Shapes Table Already Exists"); + m_log.Warn("[SQLITE]: Shapes Table Already Exists"); } if (persistPrimInventories) @@ -1528,7 +1530,7 @@ namespace OpenSim.Framework.Data.SQLite } catch (SqliteSyntaxException) { - MainLog.Instance.Warn("SQLITE", "Primitives Inventory Table Already Exists"); + m_log.Warn("[SQLITE]: Primitives Inventory Table Already Exists"); } } @@ -1538,7 +1540,7 @@ namespace OpenSim.Framework.Data.SQLite } catch (SqliteSyntaxException) { - MainLog.Instance.Warn("SQLITE", "Terrain Table Already Exists"); + m_log.Warn("[SQLITE]: Terrain Table Already Exists"); } try @@ -1547,7 +1549,7 @@ namespace OpenSim.Framework.Data.SQLite } catch (SqliteSyntaxException) { - MainLog.Instance.Warn("SQLITE", "Land Table Already Exists"); + m_log.Warn("[SQLITE]: Land Table Already Exists"); } try @@ -1556,7 +1558,7 @@ namespace OpenSim.Framework.Data.SQLite } catch (SqliteSyntaxException) { - MainLog.Instance.Warn("SQLITE", "LandAccessList Table Already Exists"); + m_log.Warn("[SQLITE]: LandAccessList Table Already Exists"); } conn.Close(); } @@ -1596,7 +1598,7 @@ namespace OpenSim.Framework.Data.SQLite } catch (SqliteSyntaxException) { - MainLog.Instance.Verbose("DATASTORE", "SQLite Database doesn't exist... creating"); + m_log.Info("[DATASTORE]: SQLite Database doesn't exist... creating"); InitDB(conn); } @@ -1614,7 +1616,7 @@ namespace OpenSim.Framework.Data.SQLite { if (!tmpDS.Tables["prims"].Columns.Contains(col.ColumnName)) { - MainLog.Instance.Verbose("DATASTORE", "Missing required column:" + col.ColumnName); + m_log.Info("[DATASTORE]: Missing required column:" + col.ColumnName); return false; } } @@ -1623,7 +1625,7 @@ namespace OpenSim.Framework.Data.SQLite { if (!tmpDS.Tables["primshapes"].Columns.Contains(col.ColumnName)) { - MainLog.Instance.Verbose("DATASTORE", "Missing required column:" + col.ColumnName); + m_log.Info("[DATASTORE]: Missing required column:" + col.ColumnName); return false; } } @@ -1634,7 +1636,7 @@ namespace OpenSim.Framework.Data.SQLite { if (!tmpDS.Tables["terrain"].Columns.Contains(col.ColumnName)) { - MainLog.Instance.Verbose("DATASTORE", "Missing require column:" + col.ColumnName); + m_log.Info("[DATASTORE]: Missing require column:" + col.ColumnName); return false; } } @@ -1643,7 +1645,7 @@ namespace OpenSim.Framework.Data.SQLite { if (!tmpDS.Tables["land"].Columns.Contains(col.ColumnName)) { - MainLog.Instance.Verbose("DATASTORE", "Missing require column:" + col.ColumnName); + m_log.Info("[DATASTORE]: Missing require column:" + col.ColumnName); return false; } } @@ -1652,7 +1654,7 @@ namespace OpenSim.Framework.Data.SQLite { if (!tmpDS.Tables["landaccesslist"].Columns.Contains(col.ColumnName)) { - MainLog.Instance.Verbose("DATASTORE", "Missing require column:" + col.ColumnName); + m_log.Info("[DATASTORE]: Missing require column:" + col.ColumnName); return false; } } diff --git a/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs b/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs index ac7340d..2316de8 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs @@ -39,6 +39,8 @@ namespace OpenSim.Framework.Data.SQLite /// public class SQLiteUserData : SQLiteBase, IUserData { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + /// /// The database manager /// @@ -89,7 +91,7 @@ namespace OpenSim.Framework.Data.SQLite } catch (SqliteSyntaxException) { - MainLog.Instance.Verbose("SQLITE", "userfriends table not found, creating.... "); + m_log.Info("[SQLITE]: userfriends table not found, creating.... "); InitDB(conn); daf.Fill(ds.Tables["userfriends"]); } @@ -217,7 +219,7 @@ namespace OpenSim.Framework.Data.SQLite } catch (Exception ex) { - MainLog.Instance.Error("USER", "Exception getting friends list for user: " + ex.ToString()); + m_log.Error("[USER]: Exception getting friends list for user: " + ex.ToString()); } } @@ -231,7 +233,7 @@ namespace OpenSim.Framework.Data.SQLite public void UpdateUserCurrentRegion(LLUUID avatarid, LLUUID regionuuid) { - MainLog.Instance.Verbose("USER", "Stub UpdateUserCUrrentRegion called"); + m_log.Info("[USER]: Stub UpdateUserCUrrentRegion called"); } @@ -339,7 +341,7 @@ namespace OpenSim.Framework.Data.SQLite DataRow row = users.Rows.Find(Util.ToRawUuidString(AgentID)); if (row == null) { - MainLog.Instance.Warn("WEBLOGIN", "Unable to store new web login key for non-existant user"); + m_log.Warn("[WEBLOGIN]: Unable to store new web login key for non-existant user"); } else { @@ -411,7 +413,7 @@ namespace OpenSim.Framework.Data.SQLite } } - MainLog.Instance.Verbose("SQLITE", + m_log.Info("[SQLITE]: " + "Syncing user database: " + ds.Tables["users"].Rows.Count + " users stored"); // save changes off to disk da.Update(ds, "users"); @@ -775,7 +777,7 @@ namespace OpenSim.Framework.Data.SQLite } catch (System.Exception) { - MainLog.Instance.Verbose("USERS", "users table already exists"); + m_log.Info("[USERS]: users table already exists"); } try @@ -784,7 +786,7 @@ namespace OpenSim.Framework.Data.SQLite } catch (System.Exception) { - MainLog.Instance.Verbose("USERS", "userfriends table already exists"); + m_log.Info("[USERS]: userfriends table already exists"); } conn.Close(); @@ -807,7 +809,7 @@ namespace OpenSim.Framework.Data.SQLite } catch (SqliteSyntaxException) { - MainLog.Instance.Verbose("DATASTORE", "SQLite Database doesn't exist... creating"); + m_log.Info("[DATASTORE]: SQLite Database doesn't exist... creating"); InitDB(conn); } conn.Open(); diff --git a/OpenSim/Framework/Data/Properties/AssemblyInfo.cs b/OpenSim/Framework/Data/Properties/AssemblyInfo.cs index 57cf4cf..4ef500c 100644 --- a/OpenSim/Framework/Data/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/Data/Properties/AssemblyInfo.cs @@ -63,4 +63,4 @@ using System.Runtime.InteropServices; // by using the '*' as shown below: [assembly : AssemblyVersion("1.0.0.0")] -[assembly : AssemblyFileVersion("1.0.0.0")] \ No newline at end of file +[assembly : AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim/Framework/EstateSettings.cs b/OpenSim/Framework/EstateSettings.cs index b5a3468..26924eb 100644 --- a/OpenSim/Framework/EstateSettings.cs +++ b/OpenSim/Framework/EstateSettings.cs @@ -28,11 +28,14 @@ using System; using System.IO; using libsecondlife; +using OpenSim.Framework.Console; namespace OpenSim.Framework { public class EstateSettings { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + //Settings to this island private float m_billableFactor; @@ -734,7 +737,7 @@ namespace OpenSim.Framework } else { - OpenSim.Framework.Console.MainLog.Instance.Error("ESTATESETTINGS", "Unable to locate estate manager : " + avatarID.ToString() + " for removal"); + m_log.Error("[ESTATESETTINGS]: Unable to locate estate manager : " + avatarID.ToString() + " for removal"); } } @@ -749,7 +752,7 @@ namespace OpenSim.Framework { configMember = new ConfigurationMember(Path.Combine(Util.configDir(), "estate_settings.xml"), "ESTATE SETTINGS", - loadConfigurationOptions, handleIncomingConfiguration,true); + loadConfigurationOptions, handleIncomingConfiguration, true); configMember.performConfigurationRetrieve(); } } diff --git a/OpenSim/Framework/GridConfig.cs b/OpenSim/Framework/GridConfig.cs index 61a53d7..0723756 100644 --- a/OpenSim/Framework/GridConfig.cs +++ b/OpenSim/Framework/GridConfig.cs @@ -27,6 +27,7 @@ */ using System; +using OpenSim.Framework.Console; namespace OpenSim.Framework { diff --git a/OpenSim/Framework/InventoryConfig.cs b/OpenSim/Framework/InventoryConfig.cs index 108e7ff..0c13df5 100644 --- a/OpenSim/Framework/InventoryConfig.cs +++ b/OpenSim/Framework/InventoryConfig.cs @@ -26,6 +26,8 @@ * */ +using OpenSim.Framework.Console; + namespace OpenSim.Framework { /// diff --git a/OpenSim/Framework/MessageServerConfig.cs b/OpenSim/Framework/MessageServerConfig.cs index ccb6e7a..c7fee85 100644 --- a/OpenSim/Framework/MessageServerConfig.cs +++ b/OpenSim/Framework/MessageServerConfig.cs @@ -28,6 +28,7 @@ using System; using System.Collections.Generic; using System.Text; +using OpenSim.Framework.Console; namespace OpenSim.Framework { diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 751ca9d..e953182 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs @@ -31,6 +31,7 @@ using System.Net.Sockets; using System.Xml; using libsecondlife; using Nini.Config; +using OpenSim.Framework.Console; namespace OpenSim.Framework { @@ -176,7 +177,7 @@ namespace OpenSim.Framework public string MasterAvatarSandboxPassword = String.Empty; // Apparently, we're applying the same estatesettings regardless of whether it's local or remote. - private static EstateSettings m_estateSettings; + private EstateSettings m_estateSettings; public EstateSettings EstateSettings { @@ -196,7 +197,7 @@ namespace OpenSim.Framework public RegionInfo(string description, string filename, bool skipConsoleConfig) { configMember = - new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration,!skipConsoleConfig); + new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration, !skipConsoleConfig); configMember.performConfigurationRetrieve(); } diff --git a/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs b/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs index 8a1a038..76d0b34 100644 --- a/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs +++ b/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs @@ -35,6 +35,8 @@ namespace OpenSim.Framework.RegionLoader.Web { public class RegionLoaderWebServer : IRegionLoader { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private IniConfigSource m_configSouce; public void SetIniConfigSource(IniConfigSource configSource) @@ -46,7 +48,7 @@ namespace OpenSim.Framework.RegionLoader.Web { if (m_configSouce == null) { - MainLog.Instance.Error("WEBLOADER", "Unable to load configuration source!"); + m_log.Error("[WEBLOADER]: Unable to load configuration source!"); return null; } else @@ -55,16 +57,16 @@ namespace OpenSim.Framework.RegionLoader.Web string url = startupConfig.GetString("regionload_webserver_url", System.String.Empty).Trim(); if (url == System.String.Empty) { - MainLog.Instance.Error("WEBLOADER", "Unable to load webserver URL - URL was empty."); + m_log.Error("[WEBLOADER]: Unable to load webserver URL - URL was empty."); return null; } else { HttpWebRequest webRequest = (HttpWebRequest) WebRequest.Create(url); webRequest.Timeout = 30000; //30 Second Timeout - MainLog.Instance.Debug("WEBLOADER", "Sending Download Request..."); + m_log.Debug("[WEBLOADER]: Sending Download Request..."); HttpWebResponse webResponse = (HttpWebResponse) webRequest.GetResponse(); - MainLog.Instance.Debug("WEBLOADER", "Downloading Region Information From Remote Server..."); + m_log.Debug("[WEBLOADER]: Downloading Region Information From Remote Server..."); StreamReader reader = new StreamReader(webResponse.GetResponseStream()); string xmlSource = System.String.Empty; string tempStr = reader.ReadLine(); @@ -73,9 +75,8 @@ namespace OpenSim.Framework.RegionLoader.Web xmlSource = xmlSource + tempStr; tempStr = reader.ReadLine(); } - MainLog.Instance.Debug("WEBLOADER", - "Done downloading region information from server. Total Bytes: " + - xmlSource.Length); + m_log.Debug("[WEBLOADER]: Done downloading region information from server. Total Bytes: " + + xmlSource.Length); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlSource); if (xmlDoc.FirstChild.Name == "Regions") @@ -84,7 +85,7 @@ namespace OpenSim.Framework.RegionLoader.Web int i; for (i = 0; i < xmlDoc.FirstChild.ChildNodes.Count; i++) { - MainLog.Instance.Debug(xmlDoc.FirstChild.ChildNodes[i].OuterXml); + m_log.Debug(xmlDoc.FirstChild.ChildNodes[i].OuterXml); regionInfos[i] = new RegionInfo("REGION CONFIG #" + (i + 1), xmlDoc.FirstChild.ChildNodes[i],false); } diff --git a/OpenSim/Framework/Servers/BaseHttpServer.cs b/OpenSim/Framework/Servers/BaseHttpServer.cs index df3b049..cc0c0d0 100644 --- a/OpenSim/Framework/Servers/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/BaseHttpServer.cs @@ -41,6 +41,8 @@ namespace OpenSim.Framework.Servers { public class BaseHttpServer { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + protected Thread m_workerThread; protected HttpListener m_httpListener; protected Dictionary m_rpcHandlers = new Dictionary(); @@ -296,7 +298,7 @@ namespace OpenSim.Framework.Servers } catch (Exception ex) { - MainLog.Instance.Warn("HTTPD", "Error - " + ex.Message); + m_log.Warn("[HTTPD]: Error - " + ex.Message); } finally { @@ -319,7 +321,7 @@ namespace OpenSim.Framework.Servers LLSD llsdResponse = null; try { llsdRequest = LLSDParser.DeserializeXml(requestBody); } - catch (Exception ex) { MainLog.Instance.Warn("HTTPD", "Error - " + ex.Message); } + catch (Exception ex) { m_log.Warn("[HTTPD]: Error - " + ex.Message); } if (llsdRequest != null && m_llsdHandler != null) { @@ -348,7 +350,7 @@ namespace OpenSim.Framework.Servers } catch (Exception ex) { - MainLog.Instance.Warn("HTTPD", "Error - " + ex.Message); + m_log.Warn("[HTTPD]: Error - " + ex.Message); } finally { @@ -396,7 +398,7 @@ namespace OpenSim.Framework.Servers foreach (string headername in rHeaders) { - //MainLog.Instance.Warn("HEADER", headername + "=" + request.Headers[headername]); + //m_log.Warn("[HEADER]: " + headername + "=" + request.Headers[headername]); headervals[headername] = request.Headers[headername]; } @@ -407,9 +409,9 @@ namespace OpenSim.Framework.Servers if (keysvals.Contains("method")) { - //MainLog.Instance.Warn("HTTP", "Contains Method"); + //m_log.Warn("[HTTP]: Contains Method"); string method = (string) keysvals["method"]; - //MainLog.Instance.Warn("HTTP", requestBody); + //m_log.Warn("[HTTP]: " + requestBody); GenericHTTPMethod requestprocessor; bool foundHandler = TryGetHTTPHandler(method, out requestprocessor); if (foundHandler) @@ -422,13 +424,13 @@ namespace OpenSim.Framework.Servers } else { - //MainLog.Instance.Warn("HTTP", "Handler Not Found"); + //m_log.Warn("[HTTP]: Handler Not Found"); SendHTML404(response, host); } } else { - //MainLog.Instance.Warn("HTTP", "No Method specified"); + //m_log.Warn("[HTTP]: No Method specified"); SendHTML404(response, host); } } @@ -461,7 +463,7 @@ namespace OpenSim.Framework.Servers } catch (Exception ex) { - MainLog.Instance.Warn("HTTPD", "Error - " + ex.Message); + m_log.Warn("[HTTPD]: Error - " + ex.Message); } finally { @@ -488,7 +490,7 @@ namespace OpenSim.Framework.Servers } catch (Exception ex) { - MainLog.Instance.Warn("HTTPD", "Error - " + ex.Message); + m_log.Warn("[HTTPD]: Error - " + ex.Message); } finally { @@ -513,7 +515,7 @@ namespace OpenSim.Framework.Servers } catch (Exception ex) { - MainLog.Instance.Warn("HTTPD", "Error - " + ex.Message); + m_log.Warn("[HTTPD]: Error - " + ex.Message); } finally { @@ -523,7 +525,7 @@ namespace OpenSim.Framework.Servers public void Start() { - MainLog.Instance.Verbose("HTTPD", "Starting up HTTP Server"); + m_log.Info("[HTTPD]: Starting up HTTP Server"); m_workerThread = new Thread(new ThreadStart(StartHTTP)); m_workerThread.IsBackground = true; @@ -534,7 +536,7 @@ namespace OpenSim.Framework.Servers { try { - MainLog.Instance.Verbose("HTTPD", "Spawned main thread OK"); + m_log.Info("[HTTPD]: Spawned main thread OK"); m_httpListener = new HttpListener(); if (!m_ssl) @@ -556,7 +558,7 @@ namespace OpenSim.Framework.Servers } catch (Exception e) { - MainLog.Instance.Warn("HTTPD", "Error - " + e.Message); + m_log.Warn("[HTTPD]: Error - " + e.Message); } } diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index 3016715..4831446 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -27,7 +27,6 @@ */ using System; - using OpenSim.Framework.Console; namespace OpenSim.Framework.Servers @@ -37,8 +36,7 @@ namespace OpenSim.Framework.Servers /// public abstract class BaseOpenSimServer { - protected LogBase m_log; - + protected ConsoleBase m_console; protected DateTime m_startuptime; public BaseOpenSimServer() @@ -56,7 +54,7 @@ namespace OpenSim.Framework.Servers switch (command) { case "help": - m_log.Notice("show uptime - show server startup and uptime."); + m_console.Notice("show uptime - show server startup and uptime."); break; case "show": @@ -77,8 +75,8 @@ namespace OpenSim.Framework.Servers switch (ShowWhat) { case "uptime": - m_log.Notice("Server has been running since " + m_startuptime.ToString()); - m_log.Notice("That is " + (DateTime.Now - m_startuptime).ToString()); + m_console.Notice("Server has been running since " + m_startuptime.ToString()); + m_console.Notice("That is " + (DateTime.Now - m_startuptime).ToString()); break; } } diff --git a/OpenSim/Framework/Servers/CheckSumServer.cs b/OpenSim/Framework/Servers/CheckSumServer.cs index 47b3f24..6599d86 100644 --- a/OpenSim/Framework/Servers/CheckSumServer.cs +++ b/OpenSim/Framework/Servers/CheckSumServer.cs @@ -31,7 +31,7 @@ namespace OpenSim.Framework.Servers /* public class CheckSumServer : UDPServerBase { - //protected ConsoleBase m_log; + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); public CheckSumServer(int port) : base(port) @@ -114,7 +114,7 @@ namespace OpenSim.Framework.Servers } catch (Exception) { - MainLog.Instance.Warn("CheckSumServer.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection "); + m_log.Warn("CheckSumServer.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection "); } } diff --git a/OpenSim/Framework/UserConfig.cs b/OpenSim/Framework/UserConfig.cs index a4b8a5d..3a2f384 100644 --- a/OpenSim/Framework/UserConfig.cs +++ b/OpenSim/Framework/UserConfig.cs @@ -27,6 +27,7 @@ */ using System; +using OpenSim.Framework.Console; namespace OpenSim.Framework { -- cgit v1.1