mirror of
https://github.com/opensim/opensim.git
synced 2026-08-10 11:33:28 +08:00
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.
This commit is contained in:
@@ -42,6 +42,8 @@ namespace OpenSim.Grid.UserServer
|
||||
/// </summary>
|
||||
public class OpenUser_Main : BaseOpenSimServer, conscmd_callback
|
||||
{
|
||||
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private UserConfig Cfg;
|
||||
|
||||
public UserManager m_userManager;
|
||||
@@ -53,7 +55,9 @@ namespace OpenSim.Grid.UserServer
|
||||
[STAThread]
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Launching UserServer...");
|
||||
log4net.Config.XmlConfigurator.Configure();
|
||||
|
||||
m_log.Info("Launching UserServer...");
|
||||
|
||||
OpenUser_Main userserver = new OpenUser_Main();
|
||||
|
||||
@@ -63,22 +67,17 @@ namespace OpenSim.Grid.UserServer
|
||||
|
||||
private OpenUser_Main()
|
||||
{
|
||||
if (!Directory.Exists(Util.logDir()))
|
||||
{
|
||||
Directory.CreateDirectory(Util.logDir());
|
||||
}
|
||||
m_log =
|
||||
new LogBase((Path.Combine(Util.logDir(), "opengrid-userserver-console.log")), "OpenUser", this, true);
|
||||
MainLog.Instance = m_log;
|
||||
m_console = new ConsoleBase("OpenUser", this);
|
||||
MainConsole.Instance = m_console;
|
||||
}
|
||||
|
||||
private void Work()
|
||||
{
|
||||
m_log.Notice("Enter help for a list of commands\n");
|
||||
m_console.Notice("Enter help for a list of commands\n");
|
||||
|
||||
while (true)
|
||||
{
|
||||
m_log.MainLogPrompt();
|
||||
m_console.Prompt();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +87,7 @@ namespace OpenSim.Grid.UserServer
|
||||
|
||||
StatsManager.StartCollectingUserStats();
|
||||
|
||||
MainLog.Instance.Verbose("REGION", "Establishing data connection");
|
||||
m_log.Info("[REGION]: Establishing data connection");
|
||||
m_userManager = new UserManager();
|
||||
m_userManager._config = Cfg;
|
||||
m_userManager.AddPlugin(Cfg.DatabaseProvider);
|
||||
@@ -96,11 +95,11 @@ namespace OpenSim.Grid.UserServer
|
||||
m_loginService = new UserLoginService(
|
||||
m_userManager, new LibraryRootFolder(), Cfg, Cfg.DefaultStartupMsg);
|
||||
|
||||
m_messagesService = new MessageServersConnector(MainLog.Instance);
|
||||
m_messagesService = new MessageServersConnector();
|
||||
|
||||
m_loginService.OnUserLoggedInAtLocation += NotifyMessageServersUserLoggedInToLocation;
|
||||
|
||||
MainLog.Instance.Verbose("REGION", "Starting HTTP process");
|
||||
m_log.Info("[REGION]: Starting HTTP process");
|
||||
BaseHttpServer httpServer = new BaseHttpServer(Cfg.HttpPort);
|
||||
|
||||
httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod);
|
||||
@@ -128,10 +127,9 @@ namespace OpenSim.Grid.UserServer
|
||||
new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod));
|
||||
|
||||
httpServer.Start();
|
||||
m_log.Status("SERVER", "Userserver 0.4 - Startup complete");
|
||||
m_log.Info("[SERVER]: Userserver 0.4 - Startup complete");
|
||||
}
|
||||
|
||||
|
||||
public void do_create(string what)
|
||||
{
|
||||
switch (what)
|
||||
@@ -143,11 +141,11 @@ namespace OpenSim.Grid.UserServer
|
||||
uint regX = 1000;
|
||||
uint regY = 1000;
|
||||
|
||||
tempfirstname = m_log.CmdPrompt("First name");
|
||||
templastname = m_log.CmdPrompt("Last name");
|
||||
tempMD5Passwd = m_log.PasswdPrompt("Password");
|
||||
regX = Convert.ToUInt32(m_log.CmdPrompt("Start Region X"));
|
||||
regY = Convert.ToUInt32(m_log.CmdPrompt("Start Region Y"));
|
||||
tempfirstname = m_console.CmdPrompt("First name");
|
||||
templastname = m_console.CmdPrompt("Last name");
|
||||
tempMD5Passwd = m_console.PasswdPrompt("Password");
|
||||
regX = Convert.ToUInt32(m_console.CmdPrompt("Start Region X"));
|
||||
regY = Convert.ToUInt32(m_console.CmdPrompt("Start Region Y"));
|
||||
|
||||
tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + String.Empty);
|
||||
|
||||
@@ -158,7 +156,7 @@ namespace OpenSim.Grid.UserServer
|
||||
m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY);
|
||||
} catch (Exception ex)
|
||||
{
|
||||
m_log.Error("SERVER", "Error creating user: {0}", ex.ToString());
|
||||
m_log.Error(String.Format("[SERVER]: Error creating user: {0}", ex.ToString()));
|
||||
}
|
||||
|
||||
try
|
||||
@@ -168,7 +166,7 @@ namespace OpenSim.Grid.UserServer
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
m_log.Error("SERVER", "Error creating inventory for user: {0}", ex.ToString());
|
||||
m_log.Error(String.Format("[SERVER]: Error creating inventory for user: {0}", ex.ToString()));
|
||||
}
|
||||
m_lastCreatedUser = userID;
|
||||
break;
|
||||
@@ -182,9 +180,9 @@ namespace OpenSim.Grid.UserServer
|
||||
switch (cmd)
|
||||
{
|
||||
case "help":
|
||||
m_log.Notice("create user - create a new user");
|
||||
m_log.Notice("stats - statistical information for this server");
|
||||
m_log.Notice("shutdown - shutdown the grid (USE CAUTION!)");
|
||||
m_console.Notice("create user - create a new user");
|
||||
m_console.Notice("stats - statistical information for this server");
|
||||
m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)");
|
||||
break;
|
||||
|
||||
case "create":
|
||||
@@ -193,12 +191,12 @@ namespace OpenSim.Grid.UserServer
|
||||
|
||||
case "shutdown":
|
||||
m_loginService.OnUserLoggedInAtLocation -= NotifyMessageServersUserLoggedInToLocation;
|
||||
m_log.Close();
|
||||
m_console.Close();
|
||||
Environment.Exit(0);
|
||||
break;
|
||||
|
||||
case "stats":
|
||||
MainLog.Instance.Notice("STATS", Environment.NewLine + StatsManager.UserStats.Report());
|
||||
m_console.Notice(StatsManager.UserStats.Report());
|
||||
break;
|
||||
|
||||
case "test-inventory":
|
||||
@@ -218,8 +216,9 @@ namespace OpenSim.Grid.UserServer
|
||||
|
||||
public void TestResponse(List<InventoryFolderBase> resp)
|
||||
{
|
||||
Console.WriteLine("response got");
|
||||
m_console.Notice("response got");
|
||||
}
|
||||
|
||||
public void NotifyMessageServersUserLoggedInToLocation(LLUUID agentID, LLUUID sessionID, LLUUID RegionID, ulong regionhandle, LLVector3 Position)
|
||||
{
|
||||
m_messagesService.TellMessageServersAboutUser(agentID, sessionID, RegionID, regionhandle, Position);
|
||||
|
||||
@@ -39,15 +39,14 @@ using OpenSim.Framework.Servers;
|
||||
|
||||
namespace OpenSim.Grid.UserServer
|
||||
{
|
||||
|
||||
public class MessageServersConnector
|
||||
{
|
||||
private LogBase m_log;
|
||||
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public Dictionary<string, MessageServerInfo> MessageServers;
|
||||
|
||||
public MessageServersConnector(LogBase log)
|
||||
public MessageServersConnector()
|
||||
{
|
||||
m_log=log;
|
||||
MessageServers = new Dictionary<string, MessageServerInfo>();
|
||||
}
|
||||
|
||||
@@ -65,7 +64,7 @@ namespace OpenSim.Grid.UserServer
|
||||
{
|
||||
if (!MessageServers.ContainsKey(URI))
|
||||
{
|
||||
m_log.Warn("MSGSERVER", "Got addResponsibleRegion Request for a MessageServer that isn't registered");
|
||||
m_log.Warn("[MSGSERVER]: Got addResponsibleRegion Request for a MessageServer that isn't registered");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -78,7 +77,7 @@ namespace OpenSim.Grid.UserServer
|
||||
{
|
||||
if (!MessageServers.ContainsKey(URI))
|
||||
{
|
||||
m_log.Warn("MSGSERVER", "Got RemoveResponsibleRegion Request for a MessageServer that isn't registered");
|
||||
m_log.Warn("[MSGSERVER]: Got RemoveResponsibleRegion Request for a MessageServer that isn't registered");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -175,10 +174,7 @@ namespace OpenSim.Grid.UserServer
|
||||
|
||||
XmlRpcRequest GridReq = new XmlRpcRequest("login_to_simulator", SendParams);
|
||||
XmlRpcResponse GridResp = GridReq.Send(serv.URI, 6000);
|
||||
m_log.Verbose("LOGIN","Notified : " + serv.URI + " about user login");
|
||||
|
||||
m_log.Info("[LOGIN]: Notified : " + serv.URI + " about user login");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,9 +46,10 @@ namespace OpenSim.Grid.UserServer
|
||||
{
|
||||
public delegate void UserLoggedInAtLocation(LLUUID agentID, LLUUID sessionID, LLUUID RegionID, ulong regionhandle, LLVector3 Position);
|
||||
|
||||
|
||||
public class UserLoginService : LoginService
|
||||
{
|
||||
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public event UserLoggedInAtLocation OnUserLoggedInAtLocation;
|
||||
|
||||
public UserConfig m_config;
|
||||
@@ -70,7 +71,7 @@ namespace OpenSim.Grid.UserServer
|
||||
{
|
||||
bool tryDefault = false;
|
||||
//CFK: Since the try is always "tried", the "Home Location" message should always appear, so comment this one.
|
||||
//CFK: MainLog.Instance.Verbose("LOGIN", "Load information from the gridserver");
|
||||
//CFK: m_log.Info("[LOGIN]: Load information from the gridserver");
|
||||
RegionProfileData SimInfo = new RegionProfileData();
|
||||
try
|
||||
{
|
||||
@@ -80,7 +81,7 @@ namespace OpenSim.Grid.UserServer
|
||||
|
||||
// Customise the response
|
||||
//CFK: This is redundant and the next message should always appear.
|
||||
//CFK: MainLog.Instance.Verbose("LOGIN", "Home Location");
|
||||
//CFK: m_log.Info("[LOGIN]: Home Location");
|
||||
response.Home = "{'region_handle':[r" + (SimInfo.regionLocX*256).ToString() + ",r" +
|
||||
(SimInfo.regionLocY*256).ToString() + "], " +
|
||||
"'position':[r" + theUser.homeLocation.X.ToString() + ",r" +
|
||||
@@ -91,7 +92,7 @@ namespace OpenSim.Grid.UserServer
|
||||
// Destination
|
||||
//CFK: The "Notifying" message always seems to appear, so subsume the data from this message into
|
||||
//CFK: the next one for X & Y and comment this one.
|
||||
//CFK: MainLog.Instance.Verbose("LOGIN", "CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX +
|
||||
//CFK: m_log.Info("[LOGIN]: CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX +
|
||||
//CFK: "; Region Y: " + SimInfo.regionLocY);
|
||||
response.SimAddress = Util.GetHostFromDNS(SimInfo.serverIP).ToString();
|
||||
response.SimPort = (uint) SimInfo.serverPort;
|
||||
@@ -105,7 +106,7 @@ namespace OpenSim.Grid.UserServer
|
||||
// Notify the target of an incoming user
|
||||
//CFK: The "Notifying" message always seems to appear, so subsume the data from this message into
|
||||
//CFK: the next one for X & Y and comment this one.
|
||||
//CFK: MainLog.Instance.Verbose("LOGIN", SimInfo.regionName + " (" + SimInfo.serverURI + ") " +
|
||||
//CFK: m_log.Info("[LOGIN]: " + SimInfo.regionName + " (" + SimInfo.serverURI + ") " +
|
||||
//CFK: SimInfo.regionLocX + "," + SimInfo.regionLocY);
|
||||
|
||||
// Prepare notification
|
||||
@@ -128,7 +129,7 @@ namespace OpenSim.Grid.UserServer
|
||||
theUser.currentAgent.currentRegion = SimInfo.UUID;
|
||||
theUser.currentAgent.currentHandle = SimInfo.regionHandle;
|
||||
|
||||
MainLog.Instance.Verbose("LOGIN", SimInfo.regionName + " @ " + SimInfo.httpServerURI + " " +
|
||||
m_log.Info("[LOGIN]: " + SimInfo.regionName + " @ " + SimInfo.httpServerURI + " " +
|
||||
SimInfo.regionLocX + "," + SimInfo.regionLocY);
|
||||
|
||||
XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams);
|
||||
@@ -145,9 +146,8 @@ namespace OpenSim.Grid.UserServer
|
||||
|
||||
ulong defaultHandle = (((ulong) m_config.DefaultX*256) << 32) | ((ulong) m_config.DefaultY*256);
|
||||
|
||||
MainLog.Instance.Warn(
|
||||
"LOGIN",
|
||||
"Home region not available: sending to default " + defaultHandle.ToString());
|
||||
m_log.Warn(
|
||||
"[LOGIN]: Home region not available: sending to default " + defaultHandle.ToString());
|
||||
|
||||
SimInfo = new RegionProfileData();
|
||||
try
|
||||
@@ -157,7 +157,7 @@ namespace OpenSim.Grid.UserServer
|
||||
m_config.GridSendKey, m_config.GridRecvKey);
|
||||
|
||||
// Customise the response
|
||||
MainLog.Instance.Verbose("LOGIN", "Home Location");
|
||||
m_log.Info("[LOGIN]: Home Location");
|
||||
response.Home = "{'region_handle':[r" + (SimInfo.regionLocX*256).ToString() + ",r" +
|
||||
(SimInfo.regionLocY*256).ToString() + "], " +
|
||||
"'position':[r" + theUser.homeLocation.X.ToString() + ",r" +
|
||||
@@ -166,9 +166,9 @@ namespace OpenSim.Grid.UserServer
|
||||
theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}";
|
||||
|
||||
// Destination
|
||||
MainLog.Instance.Verbose("LOGIN",
|
||||
"CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " +
|
||||
SimInfo.regionLocY);
|
||||
m_log.Info("[LOGIN]: " +
|
||||
"CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " +
|
||||
SimInfo.regionLocY);
|
||||
response.SimAddress = Util.GetHostFromDNS(SimInfo.serverIP).ToString();
|
||||
response.SimPort = (uint) SimInfo.serverPort;
|
||||
response.RegionX = SimInfo.regionLocX;
|
||||
@@ -179,7 +179,7 @@ namespace OpenSim.Grid.UserServer
|
||||
response.SeedCapability = SimInfo.httpServerURI + "CAPS/" + capsPath + "0000/";
|
||||
|
||||
// Notify the target of an incoming user
|
||||
MainLog.Instance.Verbose("LOGIN", "Notifying " + SimInfo.regionName + " (" + SimInfo.serverURI + ")");
|
||||
m_log.Info("[LOGIN]: Notifying " + SimInfo.regionName + " (" + SimInfo.serverURI + ")");
|
||||
|
||||
// Update agent with target sim
|
||||
theUser.currentAgent.currentRegion = SimInfo.UUID;
|
||||
@@ -201,7 +201,7 @@ namespace OpenSim.Grid.UserServer
|
||||
ArrayList SendParams = new ArrayList();
|
||||
SendParams.Add(SimParams);
|
||||
|
||||
MainLog.Instance.Verbose("LOGIN", "Informing region at " + SimInfo.httpServerURI);
|
||||
m_log.Info("[LOGIN]: Informing region at " + SimInfo.httpServerURI);
|
||||
// Send
|
||||
XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams);
|
||||
XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000);
|
||||
@@ -213,8 +213,8 @@ namespace OpenSim.Grid.UserServer
|
||||
|
||||
catch (Exception e)
|
||||
{
|
||||
MainLog.Instance.Warn("LOGIN", "Default region also not available");
|
||||
MainLog.Instance.Warn("LOGIN", e.ToString());
|
||||
m_log.Warn("[LOGIN]: Default region also not available");
|
||||
m_log.Warn("[LOGIN]: " + e.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -230,8 +230,8 @@ namespace OpenSim.Grid.UserServer
|
||||
// which does.
|
||||
if (null == folders | folders.Count == 0)
|
||||
{
|
||||
MainLog.Instance.Warn(
|
||||
"LOGIN",
|
||||
m_log.Warn(
|
||||
"[LOGIN]: " +
|
||||
"A root inventory folder for user ID " + userID + " was not found. A new set"
|
||||
+ " of empty inventory folders is being created.");
|
||||
|
||||
@@ -269,8 +269,8 @@ namespace OpenSim.Grid.UserServer
|
||||
}
|
||||
else
|
||||
{
|
||||
MainLog.Instance.Warn("LOGIN", "The root inventory folder could still not be retrieved" +
|
||||
" for user ID " + userID);
|
||||
m_log.Warn("[LOGIN]: The root inventory folder could still not be retrieved" +
|
||||
" for user ID " + userID);
|
||||
|
||||
AgentInventory userInventory = new AgentInventory();
|
||||
userInventory.CreateRootFolder(userID, false);
|
||||
|
||||
@@ -39,6 +39,8 @@ namespace OpenSim.Grid.UserServer
|
||||
{
|
||||
public class UserManager : UserManagerBase
|
||||
{
|
||||
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes an active agent session
|
||||
/// </summary>
|
||||
@@ -106,6 +108,7 @@ namespace OpenSim.Grid.UserServer
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a user profile to an XML element which can be returned
|
||||
/// </summary>
|
||||
@@ -202,7 +205,6 @@ namespace OpenSim.Grid.UserServer
|
||||
responseData["returnString"] = returnString;
|
||||
response.Value = responseData;
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
public XmlRpcResponse XmlRpcResponseXmlRPCUpdateUserFriendPerms(XmlRpcRequest request)
|
||||
@@ -212,8 +214,6 @@ namespace OpenSim.Grid.UserServer
|
||||
Hashtable responseData = new Hashtable();
|
||||
string returnString = "FALSE";
|
||||
|
||||
|
||||
|
||||
if (requestData.Contains("ownerID") && requestData.Contains("friendID") && requestData.Contains("friendPerms"))
|
||||
{
|
||||
UpdateUserFriendPerms(new LLUUID((string)requestData["ownerID"]), new LLUUID((string)requestData["friendID"]), (uint)Convert.ToInt32((string)requestData["friendPerms"]));
|
||||
@@ -233,8 +233,6 @@ namespace OpenSim.Grid.UserServer
|
||||
|
||||
List<FriendListItem> returndata = new List<FriendListItem>();
|
||||
|
||||
|
||||
|
||||
if (requestData.Contains("ownerID"))
|
||||
{
|
||||
returndata = this.GetUserFriendList(new LLUUID((string)requestData["ownerID"]));
|
||||
@@ -309,7 +307,6 @@ namespace OpenSim.Grid.UserServer
|
||||
return CreateUnknownUserErrorResponse();
|
||||
}
|
||||
|
||||
|
||||
return ProfileToXmlRPCResponse(userProfile);
|
||||
}
|
||||
|
||||
@@ -318,7 +315,6 @@ namespace OpenSim.Grid.UserServer
|
||||
XmlRpcResponse response = new XmlRpcResponse();
|
||||
Hashtable requestData = (Hashtable)request.Params[0];
|
||||
|
||||
|
||||
UserProfileData userProfile;
|
||||
|
||||
if (requestData.Contains("avatar_uuid"))
|
||||
@@ -336,17 +332,15 @@ namespace OpenSim.Grid.UserServer
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
OpenSim.Framework.Console.MainLog.Instance.Warn("LOGOUT", "Error in Logout XMLRPC Params");
|
||||
m_log.Warn("[LOGOUT]: Error in Logout XMLRPC Params");
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return CreateUnknownUserErrorResponse();
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user