Esempio n. 1
0
        public DispatcherSink(Action <IActivityMonitor> initialRegister,
                              IdentityCard identityCard,
                              TimeSpan timerDuration,
                              TimeSpan externalTimerDuration,
                              Action externalTimer,
                              Action <LogFilter?, LogLevelFilter?> filterChange,
                              bool isDefaultGrandOutput)
        {
            _initialRegister = initialRegister;
            _identityCard    = identityCard;
            _queue           = Channel.CreateUnbounded <IMulticastLogEntry?>(new UnboundedChannelOptions()
            {
                SingleReader = true
            });
            _handlers             = new List <IGrandOutputHandler>();
            _confTrigger          = new object();
            _stopTokenSource      = new CancellationTokenSource();
            _timerDuration        = timerDuration;
            _deltaTicks           = timerDuration.Ticks;
            _deltaExternalTicks   = externalTimerDuration.Ticks;
            _externalOnTimer      = externalTimer;
            _filterChange         = filterChange;
            _externalLogLock      = new object();
            _externalLogLastTime  = DateTimeStamp.MinValue;
            _isDefaultGrandOutput = isDefaultGrandOutput;
            _newConf = Array.Empty <GrandOutputConfiguration>();
            var monitor = new ActivityMonitor(applyAutoConfigurations: false);

            // We emit the identity card changed from this monitor (so we need its id).
            // But more importantly, this monitor identifier is the one of the GrandOutput: each log entry
            // references this identifier.
            _sinkMonitorId = monitor.UniqueId;
            _task          = ProcessAsync(monitor);
        }
Esempio n. 2
0
 GrandOutput(bool isDefault, GrandOutputConfiguration config)
 {
     if (config == null)
     {
         throw new ArgumentNullException(nameof(config));
     }
     // Creates the identity card and the client list first.
     _identityCard  = new IdentityCard();
     _clients       = new List <WeakReference <GrandOutputClient> >();
     _minimalFilter = LogFilter.Undefined;
     // Starts the pump thread. Its monitor will be registered
     // in this GrandOutput.
     _sink = new DispatcherSink(m => DoEnsureGrandOutputClient(m),
                                _identityCard,
                                config.TimerDuration ?? TimeSpan.FromMilliseconds(500),
                                TimeSpan.FromMinutes(5),
                                DoGarbageDeadClients,
                                OnFiltersChanged,
                                isDefault);
     ApplyConfiguration(config, waitForApplication: true);
     ActivityMonitor.StaticLogger.OnStaticLog += _sink.ExternalOrStaticLog;
 }
Esempio n. 3
0
 /// <summary>
 /// Initializes a new <see cref="IdentiCardChangedEvent"/>.
 /// </summary>
 /// <param name="c">Source of the change.</param>
 /// <param name="added">The keys and values added. Must not be empty.</param>
 /// <param name="identities">The modified identities.</param>
 public IdentiCardChangedEvent(IdentityCard c, IReadOnlyList <(string Key, string Value)> added, IReadOnlyDictionary <string, IReadOnlyCollection <string> > identities)