Пример #1
0
        public void Log <TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func <TState, Exception, string> formatter)
        {
            if (!ValidCategory())
            {
                return;
            }

            var logItem = new HistorianLogItem
            {
                Epoch      = Epoch.Now,
                LogLevel   = logLevel,
                Category   = CategoryName,
                Message    = formatter(state, exception),
                Exception  = exception,
                Exchange   = State.ContainsKey("Exchange") ? (ExchangeEnum)State["Exchange"] : (ExchangeEnum?)null,
                SymbolCode = State.ContainsKey("SymbolCode") ? (SymbolCodeEnum)State["SymbolCode"] : (SymbolCodeEnum?)null,
                Worker     = State.ContainsKey("Worker") ? (string)State["Worker"] : null,
                Protocol   = State.ContainsKey("Protocol") ? (string)State["Protocol"] : null
            };

            LoggerProvider.Enqueue(logItem);
        }