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/MessagingServer | |
parent | Cut down on the number of packets sent during terraforming. Terraforming shou... (diff) | |
download | opensim-SC_OLD-6ed5283bc06a62f38eb517e67b975832b603bf61.zip opensim-SC_OLD-6ed5283bc06a62f38eb517e67b975832b603bf61.tar.gz opensim-SC_OLD-6ed5283bc06a62f38eb517e67b975832b603bf61.tar.bz2 opensim-SC_OLD-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/MessagingServer')
-rw-r--r-- | OpenSim/Grid/MessagingServer/Main.cs | 36 | ||||
-rw-r--r-- | OpenSim/Grid/MessagingServer/MessageService.cs | 16 |
2 files changed, 23 insertions, 29 deletions
diff --git a/OpenSim/Grid/MessagingServer/Main.cs b/OpenSim/Grid/MessagingServer/Main.cs index 3d5ceb4..c16b0f8 100644 --- a/OpenSim/Grid/MessagingServer/Main.cs +++ b/OpenSim/Grid/MessagingServer/Main.cs | |||
@@ -41,6 +41,8 @@ namespace OpenSim.Grid.MessagingServer | |||
41 | /// </summary> | 41 | /// </summary> |
42 | public class OpenMessage_Main : BaseOpenSimServer, conscmd_callback | 42 | public class OpenMessage_Main : BaseOpenSimServer, conscmd_callback |
43 | { | 43 | { |
44 | private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | ||
45 | |||
44 | private MessageServerConfig Cfg; | 46 | private MessageServerConfig Cfg; |
45 | 47 | ||
46 | //public UserManager m_userManager; | 48 | //public UserManager m_userManager; |
@@ -51,7 +53,9 @@ namespace OpenSim.Grid.MessagingServer | |||
51 | [STAThread] | 53 | [STAThread] |
52 | public static void Main(string[] args) | 54 | public static void Main(string[] args) |
53 | { | 55 | { |
54 | Console.WriteLine("Launching MessagingServer..."); | 56 | log4net.Config.XmlConfigurator.Configure(); |
57 | |||
58 | m_log.Info("Launching MessagingServer..."); | ||
55 | 59 | ||
56 | OpenMessage_Main messageserver = new OpenMessage_Main(); | 60 | OpenMessage_Main messageserver = new OpenMessage_Main(); |
57 | 61 | ||
@@ -61,22 +65,17 @@ namespace OpenSim.Grid.MessagingServer | |||
61 | 65 | ||
62 | private OpenMessage_Main() | 66 | private OpenMessage_Main() |
63 | { | 67 | { |
64 | if (!Directory.Exists(Util.logDir())) | 68 | m_console = new ConsoleBase("OpenMessage", this); |
65 | { | 69 | MainConsole.Instance = m_console; |
66 | Directory.CreateDirectory(Util.logDir()); | ||
67 | } | ||
68 | m_log = | ||
69 | new LogBase((Path.Combine(Util.logDir(), "opengrid-messagingserver-console.log")), "OpenMessage", this, true); | ||
70 | MainLog.Instance = m_log; | ||
71 | } | 70 | } |
72 | 71 | ||
73 | private void Work() | 72 | private void Work() |
74 | { | 73 | { |
75 | m_log.Notice("Enter help for a list of commands\n"); | 74 | m_console.Notice("Enter help for a list of commands\n"); |
76 | 75 | ||
77 | while (true) | 76 | while (true) |
78 | { | 77 | { |
79 | m_log.MainLogPrompt(); | 78 | m_console.Prompt(); |
80 | } | 79 | } |
81 | } | 80 | } |
82 | 81 | ||
@@ -84,9 +83,7 @@ namespace OpenSim.Grid.MessagingServer | |||
84 | { | 83 | { |
85 | Cfg = new MessageServerConfig("MESSAGING SERVER", (Path.Combine(Util.configDir(), "MessagingServer_Config.xml"))); | 84 | Cfg = new MessageServerConfig("MESSAGING SERVER", (Path.Combine(Util.configDir(), "MessagingServer_Config.xml"))); |
86 | 85 | ||
87 | 86 | m_log.Info("[REGION]: Starting HTTP process"); | |
88 | |||
89 | MainLog.Instance.Verbose("REGION", "Starting HTTP process"); | ||
90 | BaseHttpServer httpServer = new BaseHttpServer(Cfg.HttpPort); | 87 | BaseHttpServer httpServer = new BaseHttpServer(Cfg.HttpPort); |
91 | 88 | ||
92 | //httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod); | 89 | //httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod); |
@@ -104,10 +101,9 @@ namespace OpenSim.Grid.MessagingServer | |||
104 | //new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod)); | 101 | //new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod)); |
105 | 102 | ||
106 | httpServer.Start(); | 103 | httpServer.Start(); |
107 | m_log.Status("SERVER", "Messageserver 0.4 - Startup complete"); | 104 | m_log.Info("[SERVER]: Messageserver 0.4 - Startup complete"); |
108 | } | 105 | } |
109 | 106 | ||
110 | |||
111 | public void do_create(string what) | 107 | public void do_create(string what) |
112 | { | 108 | { |
113 | switch (what) | 109 | switch (what) |
@@ -120,7 +116,7 @@ namespace OpenSim.Grid.MessagingServer | |||
120 | //m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY); | 116 | //m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY); |
121 | } catch (Exception ex) | 117 | } catch (Exception ex) |
122 | { | 118 | { |
123 | m_log.Error("SERVER", "Error creating user: {0}", ex.ToString()); | 119 | m_console.Error("[SERVER]: Error creating user: {0}", ex.ToString()); |
124 | } | 120 | } |
125 | 121 | ||
126 | try | 122 | try |
@@ -130,9 +126,9 @@ namespace OpenSim.Grid.MessagingServer | |||
130 | } | 126 | } |
131 | catch (Exception ex) | 127 | catch (Exception ex) |
132 | { | 128 | { |
133 | m_log.Error("SERVER", "Error creating inventory for user: {0}", ex.ToString()); | 129 | m_console.Error("[SERVER]: Error creating inventory for user: {0}", ex.ToString()); |
134 | } | 130 | } |
135 | // m_lastCreatedUser = userID; | 131 | // m_lastCreatedUser = userID; |
136 | break; | 132 | break; |
137 | } | 133 | } |
138 | } | 134 | } |
@@ -144,11 +140,11 @@ namespace OpenSim.Grid.MessagingServer | |||
144 | switch (cmd) | 140 | switch (cmd) |
145 | { | 141 | { |
146 | case "help": | 142 | case "help": |
147 | m_log.Notice("shutdown - shutdown the message server (USE CAUTION!)"); | 143 | m_console.Notice("shutdown - shutdown the message server (USE CAUTION!)"); |
148 | break; | 144 | break; |
149 | 145 | ||
150 | case "shutdown": | 146 | case "shutdown": |
151 | m_log.Close(); | 147 | m_console.Close(); |
152 | Environment.Exit(0); | 148 | Environment.Exit(0); |
153 | break; | 149 | break; |
154 | } | 150 | } |
diff --git a/OpenSim/Grid/MessagingServer/MessageService.cs b/OpenSim/Grid/MessagingServer/MessageService.cs index 056bfcb..c2669b0 100644 --- a/OpenSim/Grid/MessagingServer/MessageService.cs +++ b/OpenSim/Grid/MessagingServer/MessageService.cs | |||
@@ -43,7 +43,8 @@ namespace OpenSim.Grid.MessagingServer | |||
43 | { | 43 | { |
44 | public class MessageService | 44 | public class MessageService |
45 | { | 45 | { |
46 | private LogBase m_log; | 46 | private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
47 | |||
47 | private MessageServerConfig m_cfg; | 48 | private MessageServerConfig m_cfg; |
48 | 49 | ||
49 | //A hashtable of all current presences this server knows about | 50 | //A hashtable of all current presences this server knows about |
@@ -58,13 +59,10 @@ namespace OpenSim.Grid.MessagingServer | |||
58 | // Hashtable containing work units that need to be processed | 59 | // Hashtable containing work units that need to be processed |
59 | private Hashtable m_unProcessedWorkUnits = new Hashtable(); | 60 | private Hashtable m_unProcessedWorkUnits = new Hashtable(); |
60 | 61 | ||
61 | 62 | public MessageService(MessageServerConfig cfg) | |
62 | public MessageService(LogBase log, MessageServerConfig cfg) | ||
63 | { | 63 | { |
64 | m_log = log; | ||
65 | m_cfg = cfg; | 64 | m_cfg = cfg; |
66 | } | 65 | } |
67 | |||
68 | 66 | ||
69 | #region RegionComms Methods | 67 | #region RegionComms Methods |
70 | 68 | ||
@@ -84,7 +82,7 @@ namespace OpenSim.Grid.MessagingServer | |||
84 | ArrayList SendParams = new ArrayList(); | 82 | ArrayList SendParams = new ArrayList(); |
85 | SendParams.Add(PresenceParams); | 83 | SendParams.Add(PresenceParams); |
86 | 84 | ||
87 | MainLog.Instance.Verbose("PRESENCE", "Informing " + whichRegion.regionName + " at " + whichRegion.httpServerURI); | 85 | m_log.Info("[PRESENCE]: Informing " + whichRegion.regionName + " at " + whichRegion.httpServerURI); |
88 | // Send | 86 | // Send |
89 | XmlRpcRequest RegionReq = new XmlRpcRequest("presence_update", SendParams); | 87 | XmlRpcRequest RegionReq = new XmlRpcRequest("presence_update", SendParams); |
90 | XmlRpcResponse RegionResp = RegionReq.Send(whichRegion.httpServerURI, 6000); | 88 | XmlRpcResponse RegionResp = RegionReq.Send(whichRegion.httpServerURI, 6000); |
@@ -292,7 +290,7 @@ namespace OpenSim.Grid.MessagingServer | |||
292 | } | 290 | } |
293 | catch (WebException e) | 291 | catch (WebException e) |
294 | { | 292 | { |
295 | MainLog.Instance.Warn("Error when trying to fetch Avatar's friends list: " + | 293 | m_log.Warn("Error when trying to fetch Avatar's friends list: " + |
296 | e.Message); | 294 | e.Message); |
297 | // Return Empty list (no friends) | 295 | // Return Empty list (no friends) |
298 | } | 296 | } |
@@ -439,7 +437,7 @@ namespace OpenSim.Grid.MessagingServer | |||
439 | 437 | ||
440 | if (responseData.ContainsKey("error")) | 438 | if (responseData.ContainsKey("error")) |
441 | { | 439 | { |
442 | m_log.Error("GRID","error received from grid server" + responseData["error"]); | 440 | m_log.Error("[GRID]: error received from grid server" + responseData["error"]); |
443 | return null; | 441 | return null; |
444 | } | 442 | } |
445 | 443 | ||
@@ -465,7 +463,7 @@ namespace OpenSim.Grid.MessagingServer | |||
465 | } | 463 | } |
466 | catch (WebException) | 464 | catch (WebException) |
467 | { | 465 | { |
468 | MainLog.Instance.Error("GRID", | 466 | m_log.Error("[GRID]: " + |
469 | "Region lookup failed for: " + regionHandle.ToString() + | 467 | "Region lookup failed for: " + regionHandle.ToString() + |
470 | " - Is the GridServer down?"); | 468 | " - Is the GridServer down?"); |
471 | return null; | 469 | return null; |