CentralMine.NET.EventLog.RecordEvent C# (CSharp) Method

RecordEvent() public method

public RecordEvent ( EventType type, string evt ) : void
type EventType
evt string
return void
        public void RecordEvent(EventType type, string evt)
        {
            EventInfo info = new EventInfo();
            info.mTime = DateTime.Now;
            info.mType = type;

            if (evt.Length < 256)
                info.mEventData = evt;
            else
                info.mEventData = evt.Substring(0, 255);

            mEventQueueLock.WaitOne();
            mEventQueue.Add(info);
            mEventQueueLock.ReleaseMutex();
        }

Usage Example

        public void AcceptClient(TcpClient client)
        {
            IPEndPoint ep = client.Client.RemoteEndPoint as IPEndPoint;

            byte[] bytes = ep.Address.GetAddressBytes();
            uint   addr  = (uint)(bytes[0] << 24) | (uint)(bytes[1] << 16) | (uint)(bytes[2] << 8) | bytes[3];

            if (!mBlacklist.ContainsKey(addr))
            {
                Client c = new Client(client, this);
                mEventLog.RecordEvent(EventLog.EventType.Network, string.Format("New connection from: {0}", ep.Address.ToString()));
                mClientListMutex.WaitOne();
                mClients.Add(c);
                mClientListMutex.ReleaseMutex();
            }
        }