Ejemplo n.º 1
0
        protected override void Write(LogEventInfo logEvent)
        {
            var message = Layout.Render(logEvent);

            if (logEvent.Level == LogLevel.Debug)
            {
                monikClient.ApplicationVerbose(message);
            }
            else if (logEvent.Level == LogLevel.Error)
            {
                monikClient.LogicError(message);
            }
            else if (logEvent.Level == LogLevel.Fatal)
            {
                monikClient.LogicFatal(message);
            }
            else if (logEvent.Level == LogLevel.Info)
            {
                monikClient.LogicInfo(message);
            }
            else if (logEvent.Level == LogLevel.Trace)
            {
                monikClient.LogicVerbose(message);
            }
            else if (logEvent.Level == LogLevel.Warn)
            {
                monikClient.LogicWarning(message);
            }
        }
Ejemplo n.º 2
0
        private void OnProcessTask()
        {
            while (!_pumpCancellationTokenSource.IsCancellationRequested)
            {
                _newMessageEvent.WaitOne();

                Task.Delay(DelayOnProcess).Wait();

                try
                {
                    if (_msgBuffer.IsEmpty)
                    {
                        continue;
                    }

                    // TODO: use bulk insert and pk id generate in service !!!

                    while (_msgBuffer.TryDequeue(out Event msg))
                    {
                        var srcName  = msg.Source;
                        var instName = msg.Instance;

                        if (srcName.Trim().Length != 0 && instName.Trim().Length != 0)
                        {
                            var instance = _cache.CheckSourceAndInstance(srcName, instName);
                            _processor.Process(msg, instance);
                        }
                        // TODO: increase count of ignored messages
                    }

                    _processor.FinalizeProcessing();
                }
                catch (Exception ex)
                {
                    _monik.LogicError($"Failed to process messages: {ex}");
                }
                finally
                {
                    _newMessageEvent.Reset();
                }
            }
        }