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:
Jeff Ames
2008-02-05 19:44:27 +00:00
parent 7a61bcff86
commit 6ed5283bc0
173 changed files with 2175 additions and 1950 deletions

View File

@@ -41,8 +41,7 @@ namespace OpenSim.Region.Environment.Modules
{
public class BetaGridLikeMoneyModule: IRegionModule
{
private LogBase m_log;
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private Dictionary<ulong,Scene> m_scenel = new Dictionary<ulong,Scene>();
@@ -66,8 +65,6 @@ namespace OpenSim.Region.Environment.Modules
public void Initialise(Scene scene, IConfigSource config)
{
m_log = MainLog.Instance;
m_gConfig = config;
ReadConfigAndPopulate();
@@ -160,11 +157,8 @@ namespace OpenSim.Region.Environment.Modules
}
else
{
MainLog.Instance.Warn("MONEY", "Potential Fraud Warning, got money transfer request for avatar that isn't in this simulator - Details; Sender:" + e.sender.ToString() + " Reciver: " + e.reciever.ToString() + " Amount: " + e.amount.ToString());
m_log.Warn("[MONEY]: Potential Fraud Warning, got money transfer request for avatar that isn't in this simulator - Details; Sender:" + e.sender.ToString() + " Reciver: " + e.reciever.ToString() + " Amount: " + e.amount.ToString());
}
}
private bool doMoneyTranfer(LLUUID Sender, LLUUID Receiver, int amount)

View File

@@ -43,8 +43,9 @@ namespace OpenSim.Region.Environment.Modules
{
public class ChatModule : IRegionModule, ISimChat
{
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private List<Scene> m_scenes = new List<Scene>();
private LogBase m_log;
private int m_whisperdistance = 10;
private int m_saydistance = 30;
@@ -59,11 +60,6 @@ namespace OpenSim.Region.Environment.Modules
internal object m_syncLogout = new object();
private Thread m_irc_connector=null;
public ChatModule()
{
m_log = MainLog.Instance;
}
public void Initialise(Scene scene, IConfigSource config)
{
lock (m_syncInit)
@@ -159,7 +155,7 @@ namespace OpenSim.Region.Environment.Modules
}
catch (Exception ex)
{
m_log.Error("IRC", "NewClient exception trap:" + ex.ToString());
m_log.Error("[IRC]: NewClient exception trap:" + ex.ToString());
}
}
@@ -180,13 +176,13 @@ namespace OpenSim.Region.Environment.Modules
{
m_last_leaving_user = clientName;
m_irc.PrivMsg(m_irc.Nick, "Sim", "notices " + clientName + " left " + clientRegion);
m_log.Verbose("IRC", "IRC watcher notices " + clientName + " left " + clientRegion);
m_log.Info("[IRC]: IRC watcher notices " + clientName + " left " + clientRegion);
}
}
}
catch (Exception ex)
{
m_log.Error("IRC", "ClientLoggedOut exception trap:" + ex.ToString());
m_log.Error("[IRC]: ClientLoggedOut exception trap:" + ex.ToString());
}
}
@@ -319,6 +315,8 @@ namespace OpenSim.Region.Environment.Modules
internal class IRCChatModule
{
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private string m_server = null;
private uint m_port = 6668;
private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot";
@@ -341,7 +339,6 @@ namespace OpenSim.Region.Environment.Modules
private List<Scene> m_scenes = null;
private List<Scene> m_last_scenes = null;
private LogBase m_log;
public IRCChatModule(IConfigSource config)
{
@@ -388,9 +385,8 @@ namespace OpenSim.Region.Environment.Modules
}
catch (Exception)
{
MainLog.Instance.Verbose("CHAT", "No IRC config information, skipping IRC bridge configuration");
m_log.Info("[CHAT]: No IRC config information, skipping IRC bridge configuration");
}
m_log = MainLog.Instance;
}
public bool Connect(List<Scene> scenes)
@@ -404,9 +400,9 @@ namespace OpenSim.Region.Environment.Modules
if (m_last_scenes == null) { m_last_scenes = scenes; }
m_tcp = new TcpClient(m_server, (int)m_port);
m_log.Verbose("IRC", "Connecting...");
m_log.Info("[IRC]: Connecting...");
m_stream = m_tcp.GetStream();
m_log.Verbose("IRC", "Connected to " + m_server);
m_log.Info("[IRC]: Connected to " + m_server);
m_reader = new StreamReader(m_stream);
m_writer = new StreamWriter(m_stream);
@@ -422,7 +418,7 @@ namespace OpenSim.Region.Environment.Modules
m_writer.Flush();
m_writer.WriteLine("JOIN " + m_channel);
m_writer.Flush();
m_log.Verbose("IRC", "Connection fully established");
m_log.Info("[IRC]: Connection fully established");
m_connected = true;
}
catch (Exception e)
@@ -475,16 +471,16 @@ namespace OpenSim.Region.Environment.Modules
m_writer.WriteLine(m_privmsgformat, m_channel, from, region, msg);
}
m_writer.Flush();
m_log.Verbose("IRC", "PrivMsg " + from + " in " + region + " :" + msg);
m_log.Info("[IRC]: PrivMsg " + from + " in " + region + " :" + msg);
}
catch (IOException)
{
m_log.Error("IRC", "Disconnected from IRC server.(PrivMsg)");
m_log.Error("[IRC]: Disconnected from IRC server.(PrivMsg)");
Reconnect();
}
catch (Exception ex)
{
m_log.Error("IRC", "PrivMsg exception trap:" + ex.ToString());
m_log.Error("[IRC]: PrivMsg exception trap:" + ex.ToString());
}
}
@@ -493,7 +489,7 @@ namespace OpenSim.Region.Environment.Modules
//examines IRC commands and extracts any private messages
// which will then be reboadcast in the Sim
m_log.Verbose("IRC", "ExtractMsg: " + input);
m_log.Info("[IRC]: ExtractMsg: " + input);
Dictionary<string, string> result = null;
//string regex = @":(?<nick>\w*)!~(?<user>\S*) PRIVMSG (?<channel>\S+) :(?<msg>.*)";
string regex = @":(?<nick>\w*)!(?<user>\S*) PRIVMSG (?<channel>\S+) :(?<msg>.*)";
@@ -510,10 +506,10 @@ namespace OpenSim.Region.Environment.Modules
}
else
{
m_log.Verbose("IRC", "Number of matches: " + matches.Count);
m_log.Info("[IRC]: Number of matches: " + matches.Count);
if (matches.Count > 0)
{
m_log.Verbose("IRC", "Number of groups: " + matches[0].Groups.Count);
m_log.Info("[IRC]: Number of groups: " + matches[0].Groups.Count);
}
}
return result;
@@ -536,12 +532,12 @@ namespace OpenSim.Region.Environment.Modules
}
catch (IOException)
{
m_log.Error("IRC", "Disconnected from IRC server.(PingRun)");
m_log.Error("[IRC]: Disconnected from IRC server.(PingRun)");
Reconnect();
}
catch (Exception ex)
{
m_log.Error("IRC", "PingRun exception trap:" + ex.ToString() + "\n" + ex.StackTrace);
m_log.Error("[IRC]: PingRun exception trap:" + ex.ToString() + "\n" + ex.StackTrace);
}
}
}
@@ -552,29 +548,29 @@ namespace OpenSim.Region.Environment.Modules
LLVector3 pos = new LLVector3(128, 128, 20);
while (true)
{
try
{
while ((m_connected == true) && ((inputLine = m_reader.ReadLine()) != null))
try
{
while ((m_connected == true) && ((inputLine = m_reader.ReadLine()) != null))
{
// Console.WriteLine(inputLine);
if (inputLine.Contains(m_channel))
{
Dictionary<string, string> data = ExtractMsg(inputLine);
Dictionary<string, string> data = ExtractMsg(inputLine);
// Any chat ???
if (data != null)
{
foreach (Scene m_scene in m_scenes)
{
m_scene.ForEachScenePresence(delegate(ScenePresence avatar)
{
if (!avatar.IsChildAgent)
{
if (!avatar.IsChildAgent)
{
avatar.ControllingClient.SendChatMessage(
Helpers.StringToField(data["msg"]), 255,
pos, data["nick"],
LLUUID.Zero);
}
});
avatar.ControllingClient.SendChatMessage(
Helpers.StringToField(data["msg"]), 255,
pos, data["nick"],
LLUUID.Zero);
}
});
}
@@ -584,24 +580,24 @@ namespace OpenSim.Region.Environment.Modules
// Was an command from the IRC server
ProcessIRCCommand(inputLine);
}
}
}
else
{
// Was an command from the IRC server
ProcessIRCCommand(inputLine);
}
Thread.Sleep(150);
}
}
catch (IOException)
{
m_log.Error("IRC", "ListenerRun IOException. Disconnected from IRC server ??? (ListenerRun)");
Reconnect();
}
catch (Exception ex)
{
m_log.Error("IRC", "ListenerRun exception trap:" + ex.ToString()+"\n"+ex.StackTrace);
}
}
catch (IOException)
{
m_log.Error("[IRC]: ListenerRun IOException. Disconnected from IRC server ??? (ListenerRun)");
Reconnect();
}
catch (Exception ex)
{
m_log.Error("[IRC]: ListenerRun exception trap:" + ex.ToString() + "\n" + ex.StackTrace);
}
}
}
@@ -626,27 +622,27 @@ namespace OpenSim.Region.Environment.Modules
}
catch (Exception ex) // IRC gate should not crash Sim
{
m_log.Error("IRC", "BroadcastSim Exception Trap:" + ex.ToString() + "\n" + ex.StackTrace);
m_log.Error("[IRC]: BroadcastSim Exception Trap:" + ex.ToString() + "\n" + ex.StackTrace);
}
}
public enum ErrorReplies
{
NotRegistered = 451, // ":You have not registered"
NicknameInUse = 433 // "<nick> :Nickname is already in use"
}
public enum Replies
{
MotdStart = 375, // ":- <server> Message of the day - "
Motd = 372, // ":- <text>"
EndOfMotd = 376 // ":End of /MOTD command"
}
public void ProcessIRCCommand(string command)
{
//m_log.Verbose("IRC", "ProcessIRCCommand:"+command);
//m_log.Info("[IRC]: ProcessIRCCommand:" + command);
string[] commArgs = new string[command.Split(' ').Length];
string c_server = m_server;
@@ -656,6 +652,7 @@ namespace OpenSim.Region.Environment.Modules
{
commArgs[0] = commArgs[0].Remove(0, 1);
}
if (commArgs[1] == "002")
{
// fetch the correct servername
@@ -668,7 +665,7 @@ namespace OpenSim.Region.Environment.Modules
if (commArgs[0] == "ERROR")
{
m_log.Error("IRC", "IRC SERVER ERROR:" + command);
m_log.Error("[IRC]: IRC SERVER ERROR:" + command);
}
if (commArgs[0] == "PING")
@@ -695,7 +692,7 @@ namespace OpenSim.Region.Environment.Modules
case (int)ErrorReplies.NicknameInUse:
// Gen a new name
m_nick = m_basenick + Util.RandomClass.Next(1, 99);
m_log.Error("IRC", "IRC SERVER reports NicknameInUse, trying " + m_nick);
m_log.Error("[IRC]: IRC SERVER reports NicknameInUse, trying " + m_nick);
// Retry
m_writer.WriteLine("NICK " + m_nick);
m_writer.Flush();

View File

@@ -40,8 +40,7 @@ namespace OpenSim.Region.Environment.Modules
{
public class FriendsModule : IRegionModule
{
private LogBase m_log;
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;
@@ -49,7 +48,6 @@ namespace OpenSim.Region.Environment.Modules
public void Initialise(Scene scene, IConfigSource config)
{
m_log = MainLog.Instance;
m_scene = scene;
scene.EventManager.OnNewClient += OnNewClient;
scene.EventManager.OnGridInstantMessageToFriendsModule += OnGridInstantMessage;
@@ -72,6 +70,7 @@ namespace OpenSim.Region.Environment.Modules
}
private void OnInstantMessage(IClientAPI client,LLUUID fromAgentID,
LLUUID fromAgentSession, LLUUID toAgentID,
LLUUID imSessionID, uint timestamp, string fromAgentName,
@@ -89,13 +88,13 @@ namespace OpenSim.Region.Environment.Modules
m_pendingFriendRequests.Add(friendTransactionID, fromAgentID);
m_log.Verbose("FRIEND", "38 - From:" + fromAgentID.ToString() + " To: " + toAgentID.ToString() + " Session:" + imSessionID.ToString() + " Message:" + message);
m_log.Info("[FRIEND]: 38 - From:" + fromAgentID.ToString() + " To: " + toAgentID.ToString() + " Session:" + imSessionID.ToString() + " Message:" + message);
GridInstantMessage msg = new GridInstantMessage();
msg.fromAgentID = fromAgentID.UUID;
msg.fromAgentSession = fromAgentSession.UUID;
msg.toAgentID = toAgentID.UUID;
msg.imSessionID = friendTransactionID.UUID; // This is the item we're mucking with here
m_log.Verbose("FRIEND","Filling Session: " + msg.imSessionID.ToString());
m_log.Info("[FRIEND]: Filling Session: " + msg.imSessionID.ToString());
msg.timestamp = timestamp;
if (client != null)
{
@@ -115,20 +114,18 @@ namespace OpenSim.Region.Environment.Modules
msg.binaryBucket = binaryBucket;
m_scene.TriggerGridInstantMessage(msg, InstantMessageReceiver.IMModule);
}
if (dialog == (byte)39)
{
m_log.Verbose("FRIEND", "38 - From:" + fromAgentID.ToString() + " To: " + toAgentID.ToString() + " Session:" + imSessionID.ToString() + " Message:" + message);
}
if (dialog == (byte)40)
{
m_log.Verbose("FRIEND", "38 - From:" + fromAgentID.ToString() + " To: " + toAgentID.ToString() + " Session:" + imSessionID.ToString() + " Message:" + message);
}
// 39 == Accept Friendship
if (dialog == (byte)39)
{
m_log.Info("[FRIEND]: 39 - From:" + fromAgentID.ToString() + " To: " + toAgentID.ToString() + " Session:" + imSessionID.ToString() + " Message:" + message);
}
// 40 == Decline Friendship
if (dialog == (byte)40)
{
m_log.Info("[FRIEND]: 40 - From:" + fromAgentID.ToString() + " To: " + toAgentID.ToString() + " Session:" + imSessionID.ToString() + " Message:" + message);
}
}
private void OnApprovedFriendRequest(IClientAPI client, LLUUID agentID, LLUUID transactionID, List<LLUUID> callingCardFolders)
@@ -160,6 +157,7 @@ namespace OpenSim.Region.Environment.Modules
// TODO: Inform agent that the friend is online
}
}
private void OnDenyFriendRequest(IClientAPI client, LLUUID agentID, LLUUID transactionID, List<LLUUID> callingCardFolders)
{
if (m_pendingFriendRequests.ContainsKey(transactionID))
@@ -184,20 +182,15 @@ namespace OpenSim.Region.Environment.Modules
msg.binaryBucket = new byte[0];
m_scene.TriggerGridInstantMessage(msg, InstantMessageReceiver.IMModule);
m_pendingFriendRequests.Remove(transactionID);
}
}
private void OnTerminateFriendship(IClientAPI client, LLUUID agent, LLUUID exfriendID)
{
m_scene.StoreRemoveFriendship(agent, exfriendID);
// TODO: Inform the client that the ExFriend is offline
}
private void OnGridInstantMessage(GridInstantMessage msg)
{
// Trigger the above event handler
@@ -206,16 +199,12 @@ namespace OpenSim.Region.Environment.Modules
msg.message, msg.dialog, msg.fromGroup, msg.offline, msg.ParentEstateID,
new LLVector3(msg.Position.x, msg.Position.y, msg.Position.z), new LLUUID(msg.RegionID),
msg.binaryBucket);
}
public void PostInitialise()
{
}
public void Close()
{
}
@@ -230,4 +219,4 @@ namespace OpenSim.Region.Environment.Modules
get { return false; }
}
}
}
}

View File

@@ -39,12 +39,6 @@ namespace OpenSim.Region.Environment.Modules
public class InstantMessageModule : IRegionModule
{
private List<Scene> m_scenes = new List<Scene>();
private LogBase m_log;
public InstantMessageModule()
{
m_log = MainLog.Instance;
}
public void Initialise(Scene scene, IConfigSource config)
{
@@ -68,7 +62,6 @@ namespace OpenSim.Region.Environment.Modules
uint ParentEstateID, LLVector3 Position, LLUUID RegionID,
byte[] binaryBucket)
{
bool FriendDialog = ((dialog == (byte)38) || (dialog == (byte)39) || (dialog == (byte)40));
// IM dialogs need to be pre-processed and have their sessionID filled by the server

View File

@@ -39,6 +39,8 @@ namespace OpenSim.Region.Environment.Modules
{
public class SunModule : IRegionModule
{
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private const double m_real_day = 24.0;
private const int m_default_frame = 100;
private int m_frame_mod;
@@ -48,7 +50,6 @@ namespace OpenSim.Region.Environment.Modules
private long m_start;
private Scene m_scene;
private LogBase m_log;
public void Initialise(Scene scene, IConfigSource config)
{
@@ -69,7 +70,6 @@ namespace OpenSim.Region.Environment.Modules
m_dilation = (int) (m_real_day/m_day_length);
m_scene = scene;
m_log = MainLog.Instance;
scene.EventManager.OnFrame += SunUpdate;
scene.EventManager.OnNewClient += SunToClient;
}
@@ -104,7 +104,7 @@ namespace OpenSim.Region.Environment.Modules
m_frame++;
return;
}
// m_log.Verbose("SUN","I've got an update {0} => {1}", m_scene.RegionsInfo.RegionName, HourOfTheDay());
// m_log.Info("[SUN]: I've got an update {0} => {1}", m_scene.RegionsInfo.RegionName, HourOfTheDay());
List<ScenePresence> avatars = m_scene.GetAvatars();
foreach (ScenePresence avatar in avatars)
{
@@ -191,4 +191,4 @@ namespace OpenSim.Region.Environment.Modules
// // OutPacket(viewertime);
// }
}
}
}

View File

@@ -36,6 +36,8 @@ namespace OpenSim.Region.Environment.Modules
{
public class TextureSender
{
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public int counter = 0;
private AssetBase m_asset;
public long DataPointer = 0;
@@ -135,9 +137,8 @@ namespace OpenSim.Region.Environment.Modules
}
catch (ArgumentOutOfRangeException)
{
MainLog.Instance.Error("TEXTURE",
"Unable to separate texture into multiple packets: Array bounds failure on asset:" +
m_asset.FullID.ToString() );
m_log.Error("[TEXTURE]: Unable to separate texture into multiple packets: Array bounds failure on asset:" +
m_asset.FullID.ToString() );
return;
}
RequestUser.OutPacket(im, ThrottleOutPacketType.Texture);

View File

@@ -75,6 +75,8 @@ namespace OpenSim.Region.Environment.Modules
{
public class XMLRPCModule : IRegionModule, IXMLRPC
{
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;
private Queue<RPCRequestInfo> rpcQueue = new Queue<RPCRequestInfo>();
private object XMLRPCListLock = new object();
@@ -83,7 +85,6 @@ namespace OpenSim.Region.Environment.Modules
private int RemoteReplyScriptTimeout = 900;
private int m_remoteDataPort = 0;
private List<Scene> m_scenes = new List<Scene>();
private LogBase m_log;
// <channel id, RPCChannelInfo>
private Dictionary<LLUUID, RPCChannelInfo> m_openChannels;
@@ -91,11 +92,6 @@ namespace OpenSim.Region.Environment.Modules
// <channel id, RPCRequestInfo>
private Dictionary<LLUUID, RPCRequestInfo> m_pendingResponse;
public XMLRPCModule()
{
m_log = MainLog.Instance;
}
public void Initialise(Scene scene, IConfigSource config)
{
try
@@ -123,8 +119,8 @@ namespace OpenSim.Region.Environment.Modules
// Start http server
// Attach xmlrpc handlers
m_log.Verbose("REMOTE_DATA",
"Starting XMLRPC Server on port " + m_remoteDataPort + " for llRemoteData commands.");
m_log.Info("[REMOTE_DATA]: " +
"Starting XMLRPC Server on port " + m_remoteDataPort + " for llRemoteData commands.");
BaseHttpServer httpServer = new BaseHttpServer((uint) m_remoteDataPort);
httpServer.AddXmlRPCHandler("llRemoteData", XmlRpcRemoteData);
httpServer.Start();
@@ -413,4 +409,4 @@ namespace OpenSim.Region.Environment.Modules
return m_localID;
}
}
}
}