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/UserServer/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/UserServer/Main.cs')
-rw-r--r-- | OpenSim/Grid/UserServer/Main.cs | 55 |
1 files changed, 27 insertions, 28 deletions
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs index 32cefc1..8b9fd62 100644 --- a/OpenSim/Grid/UserServer/Main.cs +++ b/OpenSim/Grid/UserServer/Main.cs | |||
@@ -42,6 +42,8 @@ namespace OpenSim.Grid.UserServer | |||
42 | /// </summary> | 42 | /// </summary> |
43 | public class OpenUser_Main : BaseOpenSimServer, conscmd_callback | 43 | public class OpenUser_Main : BaseOpenSimServer, conscmd_callback |
44 | { | 44 | { |
45 | private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | |||
45 | private UserConfig Cfg; | 47 | private UserConfig Cfg; |
46 | 48 | ||
47 | public UserManager m_userManager; | 49 | public UserManager m_userManager; |
@@ -53,7 +55,9 @@ namespace OpenSim.Grid.UserServer | |||
53 | [STAThread] | 55 | [STAThread] |
54 | public static void Main(string[] args) | 56 | public static void Main(string[] args) |
55 | { | 57 | { |
56 | Console.WriteLine("Launching UserServer..."); | 58 | log4net.Config.XmlConfigurator.Configure(); |
59 | |||
60 | m_log.Info("Launching UserServer..."); | ||
57 | 61 | ||
58 | OpenUser_Main userserver = new OpenUser_Main(); | 62 | OpenUser_Main userserver = new OpenUser_Main(); |
59 | 63 | ||
@@ -63,22 +67,17 @@ namespace OpenSim.Grid.UserServer | |||
63 | 67 | ||
64 | private OpenUser_Main() | 68 | private OpenUser_Main() |
65 | { | 69 | { |
66 | if (!Directory.Exists(Util.logDir())) | 70 | m_console = new ConsoleBase("OpenUser", this); |
67 | { | 71 | MainConsole.Instance = m_console; |
68 | Directory.CreateDirectory(Util.logDir()); | ||
69 | } | ||
70 | m_log = | ||
71 | new LogBase((Path.Combine(Util.logDir(), "opengrid-userserver-console.log")), "OpenUser", this, true); | ||
72 | MainLog.Instance = m_log; | ||
73 | } | 72 | } |
74 | 73 | ||
75 | private void Work() | 74 | private void Work() |
76 | { | 75 | { |
77 | m_log.Notice("Enter help for a list of commands\n"); | 76 | m_console.Notice("Enter help for a list of commands\n"); |
78 | 77 | ||
79 | while (true) | 78 | while (true) |
80 | { | 79 | { |
81 | m_log.MainLogPrompt(); | 80 | m_console.Prompt(); |
82 | } | 81 | } |
83 | } | 82 | } |
84 | 83 | ||
@@ -88,7 +87,7 @@ namespace OpenSim.Grid.UserServer | |||
88 | 87 | ||
89 | StatsManager.StartCollectingUserStats(); | 88 | StatsManager.StartCollectingUserStats(); |
90 | 89 | ||
91 | MainLog.Instance.Verbose("REGION", "Establishing data connection"); | 90 | m_log.Info("[REGION]: Establishing data connection"); |
92 | m_userManager = new UserManager(); | 91 | m_userManager = new UserManager(); |
93 | m_userManager._config = Cfg; | 92 | m_userManager._config = Cfg; |
94 | m_userManager.AddPlugin(Cfg.DatabaseProvider); | 93 | m_userManager.AddPlugin(Cfg.DatabaseProvider); |
@@ -96,11 +95,11 @@ namespace OpenSim.Grid.UserServer | |||
96 | m_loginService = new UserLoginService( | 95 | m_loginService = new UserLoginService( |
97 | m_userManager, new LibraryRootFolder(), Cfg, Cfg.DefaultStartupMsg); | 96 | m_userManager, new LibraryRootFolder(), Cfg, Cfg.DefaultStartupMsg); |
98 | 97 | ||
99 | m_messagesService = new MessageServersConnector(MainLog.Instance); | 98 | m_messagesService = new MessageServersConnector(); |
100 | 99 | ||
101 | m_loginService.OnUserLoggedInAtLocation += NotifyMessageServersUserLoggedInToLocation; | 100 | m_loginService.OnUserLoggedInAtLocation += NotifyMessageServersUserLoggedInToLocation; |
102 | 101 | ||
103 | MainLog.Instance.Verbose("REGION", "Starting HTTP process"); | 102 | m_log.Info("[REGION]: Starting HTTP process"); |
104 | BaseHttpServer httpServer = new BaseHttpServer(Cfg.HttpPort); | 103 | BaseHttpServer httpServer = new BaseHttpServer(Cfg.HttpPort); |
105 | 104 | ||
106 | httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod); | 105 | httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod); |
@@ -128,10 +127,9 @@ namespace OpenSim.Grid.UserServer | |||
128 | new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod)); | 127 | new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod)); |
129 | 128 | ||
130 | httpServer.Start(); | 129 | httpServer.Start(); |
131 | m_log.Status("SERVER", "Userserver 0.4 - Startup complete"); | 130 | m_log.Info("[SERVER]: Userserver 0.4 - Startup complete"); |
132 | } | 131 | } |
133 | 132 | ||
134 | |||
135 | public void do_create(string what) | 133 | public void do_create(string what) |
136 | { | 134 | { |
137 | switch (what) | 135 | switch (what) |
@@ -143,11 +141,11 @@ namespace OpenSim.Grid.UserServer | |||
143 | uint regX = 1000; | 141 | uint regX = 1000; |
144 | uint regY = 1000; | 142 | uint regY = 1000; |
145 | 143 | ||
146 | tempfirstname = m_log.CmdPrompt("First name"); | 144 | tempfirstname = m_console.CmdPrompt("First name"); |
147 | templastname = m_log.CmdPrompt("Last name"); | 145 | templastname = m_console.CmdPrompt("Last name"); |
148 | tempMD5Passwd = m_log.PasswdPrompt("Password"); | 146 | tempMD5Passwd = m_console.PasswdPrompt("Password"); |
149 | regX = Convert.ToUInt32(m_log.CmdPrompt("Start Region X")); | 147 | regX = Convert.ToUInt32(m_console.CmdPrompt("Start Region X")); |
150 | regY = Convert.ToUInt32(m_log.CmdPrompt("Start Region Y")); | 148 | regY = Convert.ToUInt32(m_console.CmdPrompt("Start Region Y")); |
151 | 149 | ||
152 | tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + String.Empty); | 150 | tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + String.Empty); |
153 | 151 | ||
@@ -158,7 +156,7 @@ namespace OpenSim.Grid.UserServer | |||
158 | m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY); | 156 | m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY); |
159 | } catch (Exception ex) | 157 | } catch (Exception ex) |
160 | { | 158 | { |
161 | m_log.Error("SERVER", "Error creating user: {0}", ex.ToString()); | 159 | m_log.Error(String.Format("[SERVER]: Error creating user: {0}", ex.ToString())); |
162 | } | 160 | } |
163 | 161 | ||
164 | try | 162 | try |
@@ -168,7 +166,7 @@ namespace OpenSim.Grid.UserServer | |||
168 | } | 166 | } |
169 | catch (Exception ex) | 167 | catch (Exception ex) |
170 | { | 168 | { |
171 | m_log.Error("SERVER", "Error creating inventory for user: {0}", ex.ToString()); | 169 | m_log.Error(String.Format("[SERVER]: Error creating inventory for user: {0}", ex.ToString())); |
172 | } | 170 | } |
173 | m_lastCreatedUser = userID; | 171 | m_lastCreatedUser = userID; |
174 | break; | 172 | break; |
@@ -182,9 +180,9 @@ namespace OpenSim.Grid.UserServer | |||
182 | switch (cmd) | 180 | switch (cmd) |
183 | { | 181 | { |
184 | case "help": | 182 | case "help": |
185 | m_log.Notice("create user - create a new user"); | 183 | m_console.Notice("create user - create a new user"); |
186 | m_log.Notice("stats - statistical information for this server"); | 184 | m_console.Notice("stats - statistical information for this server"); |
187 | m_log.Notice("shutdown - shutdown the grid (USE CAUTION!)"); | 185 | m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)"); |
188 | break; | 186 | break; |
189 | 187 | ||
190 | case "create": | 188 | case "create": |
@@ -193,12 +191,12 @@ namespace OpenSim.Grid.UserServer | |||
193 | 191 | ||
194 | case "shutdown": | 192 | case "shutdown": |
195 | m_loginService.OnUserLoggedInAtLocation -= NotifyMessageServersUserLoggedInToLocation; | 193 | m_loginService.OnUserLoggedInAtLocation -= NotifyMessageServersUserLoggedInToLocation; |
196 | m_log.Close(); | 194 | m_console.Close(); |
197 | Environment.Exit(0); | 195 | Environment.Exit(0); |
198 | break; | 196 | break; |
199 | 197 | ||
200 | case "stats": | 198 | case "stats": |
201 | MainLog.Instance.Notice("STATS", Environment.NewLine + StatsManager.UserStats.Report()); | 199 | m_console.Notice(StatsManager.UserStats.Report()); |
202 | break; | 200 | break; |
203 | 201 | ||
204 | case "test-inventory": | 202 | case "test-inventory": |
@@ -218,8 +216,9 @@ namespace OpenSim.Grid.UserServer | |||
218 | 216 | ||
219 | public void TestResponse(List<InventoryFolderBase> resp) | 217 | public void TestResponse(List<InventoryFolderBase> resp) |
220 | { | 218 | { |
221 | Console.WriteLine("response got"); | 219 | m_console.Notice("response got"); |
222 | } | 220 | } |
221 | |||
223 | public void NotifyMessageServersUserLoggedInToLocation(LLUUID agentID, LLUUID sessionID, LLUUID RegionID, ulong regionhandle, LLVector3 Position) | 222 | public void NotifyMessageServersUserLoggedInToLocation(LLUUID agentID, LLUUID sessionID, LLUUID RegionID, ulong regionhandle, LLVector3 Position) |
224 | { | 223 | { |
225 | m_messagesService.TellMessageServersAboutUser(agentID, sessionID, RegionID, regionhandle, Position); | 224 | m_messagesService.TellMessageServersAboutUser(agentID, sessionID, RegionID, regionhandle, Position); |