diff options
author | Jeff Ames | 2008-02-05 19:44:27 +0000 |
---|---|---|
committer | Jeff Ames | 2008-02-05 19:44:27 +0000 |
commit | 6ed5283bc06a62f38eb517e67b975832b603bf61 (patch) | |
tree | e5f635018789b73a99ddeca0883a68368fa5eece /OpenSim/Grid/AssetServer/Main.cs | |
parent | Cut down on the number of packets sent during terraforming. Terraforming shou... (diff) | |
download | opensim-SC-6ed5283bc06a62f38eb517e67b975832b603bf61.zip opensim-SC-6ed5283bc06a62f38eb517e67b975832b603bf61.tar.gz opensim-SC-6ed5283bc06a62f38eb517e67b975832b603bf61.tar.bz2 opensim-SC-6ed5283bc06a62f38eb517e67b975832b603bf61.tar.xz |
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.
Diffstat (limited to 'OpenSim/Grid/AssetServer/Main.cs')
-rw-r--r-- | OpenSim/Grid/AssetServer/Main.cs | 46 |
1 files changed, 20 insertions, 26 deletions
diff --git a/OpenSim/Grid/AssetServer/Main.cs b/OpenSim/Grid/AssetServer/Main.cs index a95ea71..35e6495 100644 --- a/OpenSim/Grid/AssetServer/Main.cs +++ b/OpenSim/Grid/AssetServer/Main.cs | |||
@@ -43,6 +43,8 @@ namespace OpenSim.Grid.AssetServer | |||
43 | /// </summary> | 43 | /// </summary> |
44 | public class OpenAsset_Main : BaseOpenSimServer, conscmd_callback | 44 | public class OpenAsset_Main : BaseOpenSimServer, conscmd_callback |
45 | { | 45 | { |
46 | private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
46 | public AssetConfig m_config; | 48 | public AssetConfig m_config; |
47 | 49 | ||
48 | public static OpenAsset_Main assetserver; | 50 | public static OpenAsset_Main assetserver; |
@@ -55,7 +57,9 @@ namespace OpenSim.Grid.AssetServer | |||
55 | [STAThread] | 57 | [STAThread] |
56 | public static void Main(string[] args) | 58 | public static void Main(string[] args) |
57 | { | 59 | { |
58 | Console.WriteLine("Starting...\n"); | 60 | log4net.Config.XmlConfigurator.Configure(); |
61 | |||
62 | m_log.Info("Starting...\n"); | ||
59 | 63 | ||
60 | assetserver = new OpenAsset_Main(); | 64 | assetserver = new OpenAsset_Main(); |
61 | assetserver.Startup(); | 65 | assetserver.Startup(); |
@@ -65,42 +69,32 @@ namespace OpenSim.Grid.AssetServer | |||
65 | 69 | ||
66 | private void Work() | 70 | private void Work() |
67 | { | 71 | { |
68 | m_log.Notice("Enter help for a list of commands"); | 72 | m_console.Notice("Enter help for a list of commands"); |
69 | 73 | ||
70 | while (true) | 74 | while (true) |
71 | { | 75 | { |
72 | m_log.MainLogPrompt(); | 76 | m_console.Prompt(); |
73 | } | 77 | } |
74 | } | 78 | } |
75 | 79 | ||
76 | private OpenAsset_Main() | 80 | private OpenAsset_Main() |
77 | { | 81 | { |
78 | if (!Directory.Exists(Util.logDir())) | 82 | m_console = new ConsoleBase("OpenAsset", this); |
79 | { | ||
80 | Directory.CreateDirectory(Util.logDir()); | ||
81 | } | ||
82 | |||
83 | m_log = | ||
84 | new LogBase( | ||
85 | (Path.Combine(Util.logDir(), "opengrid-AssetServer-console.log")), | ||
86 | "OpenAsset", | ||
87 | this, | ||
88 | true); | ||
89 | 83 | ||
90 | MainLog.Instance = m_log; | 84 | MainConsole.Instance = m_console; |
91 | } | 85 | } |
92 | 86 | ||
93 | public void Startup() | 87 | public void Startup() |
94 | { | 88 | { |
95 | m_config = new AssetConfig("ASSET SERVER", (Path.Combine(Util.configDir(), "AssetServer_Config.xml"))); | 89 | m_config = new AssetConfig("ASSET SERVER", (Path.Combine(Util.configDir(), "AssetServer_Config.xml"))); |
96 | 90 | ||
97 | m_log.Verbose("ASSET", "Setting up asset DB"); | 91 | m_log.Info("[ASSET]: Setting up asset DB"); |
98 | setupDB(m_config); | 92 | setupDB(m_config); |
99 | 93 | ||
100 | m_log.Verbose("ASSET", "Loading default asset set.."); | 94 | m_log.Info("[ASSET]: Loading default asset set.."); |
101 | LoadDefaultAssets(); | 95 | LoadDefaultAssets(); |
102 | 96 | ||
103 | m_log.Verbose("ASSET", "Starting HTTP process"); | 97 | m_log.Info("[ASSET]: Starting HTTP process"); |
104 | BaseHttpServer httpServer = new BaseHttpServer(m_config.HttpPort); | 98 | BaseHttpServer httpServer = new BaseHttpServer(m_config.HttpPort); |
105 | 99 | ||
106 | StatsManager.StartCollectingAssetStats(); | 100 | StatsManager.StartCollectingAssetStats(); |
@@ -118,7 +112,7 @@ namespace OpenSim.Grid.AssetServer | |||
118 | 112 | ||
119 | public IAssetProvider LoadDatabasePlugin(string FileName) | 113 | public IAssetProvider LoadDatabasePlugin(string FileName) |
120 | { | 114 | { |
121 | MainLog.Instance.Verbose("ASSET SERVER", "LoadDatabasePlugin: Attempting to load " + FileName); | 115 | m_log.Info("[ASSET SERVER]: LoadDatabasePlugin: Attempting to load " + FileName); |
122 | Assembly pluginAssembly = Assembly.LoadFrom(FileName); | 116 | Assembly pluginAssembly = Assembly.LoadFrom(FileName); |
123 | IAssetProvider assetPlugin = null; | 117 | IAssetProvider assetPlugin = null; |
124 | foreach (Type pluginType in pluginAssembly.GetTypes()) | 118 | foreach (Type pluginType in pluginAssembly.GetTypes()) |
@@ -134,7 +128,7 @@ namespace OpenSim.Grid.AssetServer | |||
134 | assetPlugin = plug; | 128 | assetPlugin = plug; |
135 | assetPlugin.Initialise(); | 129 | assetPlugin.Initialise(); |
136 | 130 | ||
137 | MainLog.Instance.Verbose("ASSET SERVER", "Added " + assetPlugin.Name + " " + assetPlugin.Version); | 131 | m_log.Info("[ASSET SERVER]: Added " + assetPlugin.Name + " " + assetPlugin.Version); |
138 | break; | 132 | break; |
139 | } | 133 | } |
140 | 134 | ||
@@ -153,14 +147,14 @@ namespace OpenSim.Grid.AssetServer | |||
153 | m_assetProvider = LoadDatabasePlugin(config.DatabaseProvider); | 147 | m_assetProvider = LoadDatabasePlugin(config.DatabaseProvider); |
154 | if (m_assetProvider == null) | 148 | if (m_assetProvider == null) |
155 | { | 149 | { |
156 | MainLog.Instance.Error("ASSET", "Failed to load a database plugin, server halting"); | 150 | m_log.Error("[ASSET]: Failed to load a database plugin, server halting"); |
157 | Environment.Exit(-1); | 151 | Environment.Exit(-1); |
158 | } | 152 | } |
159 | } | 153 | } |
160 | catch (Exception e) | 154 | catch (Exception e) |
161 | { | 155 | { |
162 | MainLog.Instance.Warn("ASSET", "setupDB() - Exception occured"); | 156 | m_log.Warn("[ASSET]: setupDB() - Exception occured"); |
163 | MainLog.Instance.Warn("ASSET", e.ToString()); | 157 | m_log.Warn("[ASSET]: " + e.ToString()); |
164 | } | 158 | } |
165 | } | 159 | } |
166 | 160 | ||
@@ -181,18 +175,18 @@ namespace OpenSim.Grid.AssetServer | |||
181 | switch (cmd) | 175 | switch (cmd) |
182 | { | 176 | { |
183 | case "help": | 177 | case "help": |
184 | m_log.Notice( | 178 | m_console.Notice( |
185 | @"shutdown - shutdown this asset server (USE CAUTION!) | 179 | @"shutdown - shutdown this asset server (USE CAUTION!) |
186 | stats - statistical information for this server"); | 180 | stats - statistical information for this server"); |
187 | 181 | ||
188 | break; | 182 | break; |
189 | 183 | ||
190 | case "stats": | 184 | case "stats": |
191 | m_log.Notice("STATS", Environment.NewLine + StatsManager.AssetStats.Report()); | 185 | m_console.Notice("STATS", Environment.NewLine + StatsManager.AssetStats.Report()); |
192 | break; | 186 | break; |
193 | 187 | ||
194 | case "shutdown": | 188 | case "shutdown": |
195 | m_log.Close(); | 189 | m_console.Close(); |
196 | Environment.Exit(0); | 190 | Environment.Exit(0); |
197 | break; | 191 | break; |
198 | } | 192 | } |