Exemplo n.º 1
0
        /// <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);
            }
        }
Exemplo n.º 2
0
        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());
        }
Exemplo n.º 3
0
        /// <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());
        }