Esempio n. 1
0
 public DirectLogger(LogLevel minLogLevel, LogMessageRouter messageRouter, IFallbackLogger fallbackLogger,
                     MessageLayout layout)
     : this(minLogLevel, messageRouter)
 {
     _fallbackLogger = fallbackLogger;
     _layout         = layout;
 }
Esempio n. 2
0
        private void Init(DirectLoggerOptions loggerOptions, LogCastOptions logCastOptions)
        {
            Options         = loggerOptions;
            _logCastOptions = logCastOptions;
            _falbackLogger  = new FileFallbackLogger(loggerOptions.FallbackLogDirectory,
                                                     loggerOptions.DaysToKeepFallbackLogs);

            _logger = new DirectLogger(loggerOptions.MinLogLevel,
                                       new LogMessageRouter(loggerOptions.SkipPercentage),
                                       _falbackLogger,
                                       string.IsNullOrEmpty(loggerOptions.Layout) ? null : new MessageLayout(loggerOptions.Layout));
        }
Esempio n. 3
0
        public void Initialize(LogCastOptions options, IFallbackLogger fallbackLogger)
        {
            if (IsInitialized)
            {
                throw new InvalidOperationException("LogCast engine is already initialized!");
            }

            _fallbackLogger = fallbackLogger;
            _client         = _clientFactory.Create(options, fallbackLogger);
            _enableStats    = options.EnableSelfDiagnostics;

            IsInitialized = true;
        }
        public LogCastTraceListenerWorker(LogCastTraceListener listener, StringDictionary attributes, IFallbackLogger fallbackLogger)
        {
            ParseListenerOptions(attributes);
            ParseLogCastOptions(attributes);
            FallbackLogger = fallbackLogger ??
                             new FileFallbackLogger(FallbackLogDirectory, DaysToKeepFallbackLogs);

            _messageRouter = new LogMessageRouter(ParseSkipPercentage(SkipPercentage));

            // This case is mostly for scenario when a client uses trace methods directly
            // and doesn't use our ILogger/LogManager/LogConfig
            if (!LogConfig.IsConfigured && !LogConfig.IsInProgress)
            {
                LogConfig.Configure(new TraceLogManager(listener, this));
            }
        }
Esempio n. 5
0
        public LogCastClient([NotNull] LogCastOptions options, [NotNull] IFallbackLogger fallbackLogger)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            if (fallbackLogger == null)
            {
                throw new ArgumentNullException(nameof(fallbackLogger));
            }

            if (options.Endpoint == null)
            {
                fallbackLogger.Write("Endpoint cannot be null reference");
                throw new ArgumentException("Endpoint can not be null reference", nameof(options));
            }
            if (options.Throttling < 10)
            {
                fallbackLogger.Write("Throttling cannot be less than 10");
                throw new ArgumentException("Throttling can not be less than 10", nameof(options));
            }

            _options        = options;
            _fallbackLogger = fallbackLogger;
            _queue          = new BlockingCollection <LogCastMessageFactory>();

            var sendingThreadCount = _options.SendingThreadCount;
            var threadCount        = sendingThreadCount > 0 ? sendingThreadCount : 4;

            _countEvent = new CountEvent();
            Threads     = Enumerable
                          .Range(0, threadCount)
                          .Select(i => new Thread(Sender)
            {
                IsBackground = true
            })
                          .ToArray();

            foreach (var thread in Threads)
            {
                thread.Start();
            }
        }
Esempio n. 6
0
 public FailingLogCastClientMock(LogCastOptions options, IFallbackLogger fallbackLogger, int failedCount)
     : base(options, fallbackLogger)
 {
     _failedCount = failedCount;
 }
Esempio n. 7
0
 public GloballyFailingLogCastClientMock(LogCastOptions options, IFallbackLogger fallbackLogger)
     : base(options, fallbackLogger)
 {
 }
Esempio n. 8
0
 public LogCastClientMock(LogCastOptions options, IFallbackLogger fallbackLogger)
     : base(options, fallbackLogger)
 {
     Messages = new List <string>();
 }
Esempio n. 9
0
 public ILogCastClient Create(LogCastOptions options, IFallbackLogger logger)
 {
     return(new LogCastClient(options, logger));
 }
Esempio n. 10
0
        public ILogCastClient Create(LogCastOptions options, IFallbackLogger logger)
        {
            ConfiguredClient = ConfiguredClient ?? new LogCastClientMock(options);

            return(ConfiguredClient);
        }
Esempio n. 11
0
 public void Initialize(LogCastOptions options, IFallbackLogger fallbackLogger)
 {
 }