internal LoggerAdminLogger(Communicator communicator, ILogger localLogger) { LocalLogger = (localLogger as LoggerAdminLogger)?.LocalLogger ?? localLogger; _loggerAdmin = new LoggerAdmin(communicator, this); // Create an unbounded channel to ensure the messages are sent from a separate thread. We don't allow // synchronous continuations to ensure that writes on the channel are never processed by the writer // thread. _channel = Channel.CreateUnbounded <LogMessage>(new UnboundedChannelOptions { AllowSynchronousContinuations = false, SingleReader = true, SingleWriter = false }); Task.Run(async() => { // The enumeration completes when the channel writer Complete method is called. await foreach (LogMessage logMessage in _channel.Reader.ReadAllAsync()) { List <LogForwarder>?logForwarderList = _loggerAdmin.Log(logMessage); if (logForwarderList != null) { foreach (LogForwarder p in logForwarderList) { p.Queue("log", LocalLogger, prx => prx.LogAsync(logMessage)); } } } }); }
internal LogForwarder(LoggerAdmin loggerAdmin, IRemoteLoggerPrx prx, HashSet <LogMessageType> messageTypes, HashSet <string> traceCategories) { _remoteLoggerPrx = prx; _loggerAdmin = loggerAdmin; _messageTypes = messageTypes; _traceCategories = traceCategories; }
internal LoggerAdminLogger(Communicator communicator, ILogger localLogger) { if (localLogger is LoggerAdminLogger) { _localLogger = ((LoggerAdminLogger)localLogger).GetLocalLogger(); } else { _localLogger = localLogger; } _loggerAdmin = new LoggerAdmin(communicator, this); }