Пример #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);
            }
        }
Пример #2
0
        public void OnStart()
        {
            // Load metrics to instances and measures to metricobjects, from db

            var metrics            = _repository.GetAllMetrics();
            var measuresDictionary = _repository.GetAllMeasures();

            foreach (var metric in metrics)
            {
                if (!measuresDictionary.TryGetValue(metric.ID, out var measures))
                {
                    _monik.LogicWarning($"Measures for metric {metric.ID}:{metric.Name}" +
                                        $" InstId:{metric.InstanceID} not found");
                    continue;
                }
                var metObj = _autofac.Resolve <IMetricObject>();
                metObj.Load(metric, measures);

                var instance = _sourceCache.GetInstanceById(metObj.Dto.InstanceID);
                instance?.Metrics.TryAdd(metObj.Dto.Name, metObj);

                _metrics.TryAdd(metObj, 0);
            }

            foreach (var mo in _metrics.Keys)
            {
                mo.OnStart();
            }

            _shedulerPerMin.OnStart();
            _shedulerPerSec.OnStart();

            _monik.ApplicationVerbose("CacheMetric started");
        }