private void ParseLogCastOptions(StringDictionary attributes)
 {
     Options = LogCastOptions.Parse(
         attributes["endpoint"],
         attributes["throttling"],
         attributes["retryTimeout"],
         attributes["sendingThreadCount"],
         attributes["sendTimeout"],
         attributes["enableSelfDiagnostics"]);
 }
Example #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));
        }
Example #3
0
        public DirectLogManager(DirectLoggerOptions loggerOptions, LogCastOptions logCastOptions)
        {
            if (loggerOptions == null)
            {
                throw new ArgumentNullException(nameof(loggerOptions));
            }
            if (logCastOptions == null)
            {
                throw new ArgumentNullException(nameof(logCastOptions));
            }

            Init(loggerOptions, logCastOptions);
        }
Example #4
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;
        }
Example #5
0
        private void Initialize()
        {
            FallbackLogger = CreateFallbackLogger();
            Options        = LogCastOptions.Parse(
                Endpoint, Throttling, RetryTimeout, SendingThreadCount, SendTimeout, EnableSelfDiagnostics);

            _messageRouter = new LogMessageRouter(ParseSkipPercentage(SkipPercentage));

            // This case is mostly for scenario when a client uses "real" NLog LogManager
            // and doesn't use our ILogger/LogManager/LogConfig
            if (!LogConfig.IsConfigured && !LogConfig.IsInProgress)
            {
                LogConfig.Configure(new NLogManager(this));
            }
        }
Example #6
0
        public DirectLogManager()
        {
            var configuration = ConfigurationSection.Read();

            var logLevel      = (LogLevel)Enum.Parse(typeof(LogLevel), configuration.LogLevel);
            var loggerOptions = new DirectLoggerOptions(logLevel, configuration.Type)
            {
                Layout = configuration.Layout,
                FallbackLogDirectory   = configuration.FallbackLogDirectory,
                DaysToKeepFallbackLogs = configuration.DaysToKeepFallbackLogs
            };

            var logCastOptions = LogCastOptions.Parse(configuration.Endpoint, configuration.Throttling,
                                                      null, configuration.SendingThreadCount, null, configuration.EnableSelfDiagnostics);

            Init(loggerOptions, logCastOptions);
        }
Example #7
0
 public void then_throttling_10_does_not_throws()
 {
     new LogCastClient(LogCastOptions.Parse("http://host", "10", null, "10", null, null), Mock.Of <IFallbackLogger>());
 }
Example #8
0
 public void then_throttling_less_than_10_throws()
 {
     Assert.Throws <ArgumentException>(() =>
                                       new LogCastClient(LogCastOptions.Parse("http://host", "9", null, "10", null, null), Mock.Of <IFallbackLogger>()));
 }
Example #9
0
 public LogCastClientMock(LogCastOptions options)
 {
     Options = options;
 }
 public override void Act()
 {
     _cut = new LogCastOptions(Url);
 }
Example #11
0
 public FailingLogCastClientMock(LogCastOptions options, IFallbackLogger fallbackLogger, int failedCount)
     : base(options, fallbackLogger)
 {
     _failedCount = failedCount;
 }
Example #12
0
 public GloballyFailingLogCastClientMock(LogCastOptions options, IFallbackLogger fallbackLogger)
     : base(options, fallbackLogger)
 {
 }
Example #13
0
 public LogCastClientMock(LogCastOptions options, IFallbackLogger fallbackLogger)
     : base(options, fallbackLogger)
 {
     Messages = new List <string>();
 }
Example #14
0
        public ILogCastClient Create(LogCastOptions options, IFallbackLogger logger)
        {
            ConfiguredClient = ConfiguredClient ?? new LogCastClientMock(options);

            return(ConfiguredClient);
        }
Example #15
0
 public void Initialize(LogCastOptions options, IFallbackLogger fallbackLogger)
 {
 }