Exemple #1
0
        /// <summary>
        /// Logs an custom event and adds it to the list of loggers with the same profile as this logger
        /// </summary>
        /// <param name="eventName"></param>
        public async Task LogEventAsync(string eventName)
        {
            await Task.Run(async() =>
            {
                SummarizedLogger eventLogger;
                if (!eventNameMap.TryGetValue(eventName, out eventLogger))
                {
                    lock (mapAddLock)
                    {
                        if (!eventNameMap.TryGetValue(eventName, out eventLogger))
                        {
                            eventNameMap.Add(eventName, eventLogger = new SummarizedLogger(this.logger, this.LogLevel, eventName));
                            if (UseLogFrequencyEvents)
                            {
                                eventLogger.SetFrequency(this.LogFrequencyEvents);
                            }
                            else
                            {
                                eventLogger.SetFrequency(this.LogFrequencyTime);
                            }
                        }
                    }
                }

                await eventLogger.LogEventAsync();
            });
        }
 public static SummarizedLogger SetFrequency(this SummarizedLogger logger, int eventCount)
 {
     logger.LoggedEventCount = eventCount;
     return(logger);
 }
 public static SummarizedLogger SetFrequency(this SummarizedLogger logger, TimeSpan eventFrequency)
 {
     logger.LogFrequencyTime = eventFrequency;
     return(logger);
 }