/// <summary> /// Sends LoggingEvent to service /// </summary> /// <param name="data">Logging event</param> public void SendData(Qoollo.Logger.Common.LoggingEvent data) { if (data == null) { throw new ArgumentNullException("data"); } var localClient = Volatile.Read(ref _curClient); if (localClient == null || localClient.State != System.ServiceModel.CommunicationState.Opened) { throw new CommunicationException("Connection is not established. Can't send data to Log Server: " + RemoteSideName); } lock (_syncObj) { localClient = Volatile.Read(ref _curClient); if (localClient == null || localClient.State != System.ServiceModel.CommunicationState.Opened) { throw new CommunicationException("Connection is not established. Can't send data to Log Server: " + RemoteSideName); } _curClient.RemoteSide.SendData(data); } }
protected override void OnDataRecieved(Qoollo.Logger.Common.LoggingEvent data) { _mainLogger.Write(data); if (System.Threading.Interlocked.Increment(ref _receivedMsgCount) % LogPeriod == 0) LogNs.Logger.Instance.Info("Processed messages count: " + System.Threading.Interlocked.Read(ref _receivedMsgCount).ToString()); }
/// <summary> /// Сериализация объекта в бинарный вид /// </summary> /// <param name="obj">Объект</param> /// <returns></returns> public static byte[] Serialize(Qoollo.Logger.Common.LoggingEvent obj) { var serializer = LoggingEventSerializer; var ms = new MemoryStream(2048); var writer = System.Xml.XmlDictionaryWriter.CreateBinaryWriter(ms); serializer.WriteObject(writer, obj); writer.Flush(); return(ms.ToArray()); }