public DirectLogger(LogLevel minLogLevel, LogMessageRouter messageRouter, IFallbackLogger fallbackLogger, MessageLayout layout) : this(minLogLevel, messageRouter) { _fallbackLogger = fallbackLogger; _layout = layout; }
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)); }
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)); } }
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(); } }
public FailingLogCastClientMock(LogCastOptions options, IFallbackLogger fallbackLogger, int failedCount) : base(options, fallbackLogger) { _failedCount = failedCount; }
public GloballyFailingLogCastClientMock(LogCastOptions options, IFallbackLogger fallbackLogger) : base(options, fallbackLogger) { }
public LogCastClientMock(LogCastOptions options, IFallbackLogger fallbackLogger) : base(options, fallbackLogger) { Messages = new List <string>(); }
public ILogCastClient Create(LogCastOptions options, IFallbackLogger logger) { return(new LogCastClient(options, logger)); }
public ILogCastClient Create(LogCastOptions options, IFallbackLogger logger) { ConfiguredClient = ConfiguredClient ?? new LogCastClientMock(options); return(ConfiguredClient); }
public void Initialize(LogCastOptions options, IFallbackLogger fallbackLogger) { }