public void CreatingTracerWithActivityIDAndNullIServiceLocatorForInstrumentationThrows() { LogSource source = new LogSource("tracesource", SourceLevels.All); LogWriter logWriter = new LogWriterImpl(new List <ILogFilter>(), new List <LogSource>(), source, null, new LogSource("errors"), "default", false, false); new Tracer("testoperation", Guid.NewGuid(), logWriter, (IServiceLocator)null).Dispose(); }
public void CanGetLogFiltersByType() { ICollection <ILogFilter> filters = new List <ILogFilter>(); ICollection <string> categories = new List <string>(); categories.Add("cat1"); categories.Add("cat2"); categories.Add("cat3"); categories.Add("cat4"); filters.Add(new CategoryFilter("category", categories, CategoryFilterMode.AllowAllExceptDenied)); filters.Add(new PriorityFilter("priority", 100)); filters.Add(new LogEnabledFilter("enable", true)); LogWriter writer = new LogWriterImpl(filters, new Dictionary <string, LogSource>(), new LogSource("errors"), "default"); CategoryFilter categoryFilter = writer.GetFilter <CategoryFilter>(); PriorityFilter priorityFilter = writer.GetFilter <PriorityFilter>(); LogEnabledFilter enabledFilter = writer.GetFilter <LogEnabledFilter>(); Assert.IsNotNull(categoryFilter); Assert.AreEqual(4, categoryFilter.CategoryFilters.Count); Assert.IsNotNull(priorityFilter); Assert.AreEqual(100, priorityFilter.MinimumPriority); Assert.IsNotNull(enabledFilter); Assert.IsTrue(enabledFilter.Enabled); }
/// <summary> /// /// </summary> public LogCustomWriter() { _loggerType = LoggerListenerType.RollingFlatFile; var nonExistantLogSource = new LogSource("Empty"); _logWriterImpl = new LogWriterImpl(new List <ILogFilter>(), _traceSources, nonExistantLogSource, ""); }
public void DoesNotReportMissingCategoriesWhenThereAreNotMissingCategoriesAndDefaultIsNotConfigured() { Dictionary <string, LogSource> traceSources = new Dictionary <string, LogSource>(); traceSources.Add("newcat1", new LogSource("newcat1")); traceSources.Add("newcat2", new LogSource("newcat2")); traceSources.Add("newcat3", new LogSource("newcat3")); traceSources.Add("newcat4", new LogSource("newcat4")); LogSource errorsTraceSource = new LogSource("errors", SourceLevels.All); errorsTraceSource.Listeners.Add(new ErrorsMockTraceListener()); LogWriter logWriter = new LogWriterImpl(emptyFilters, traceSources, emptyTraceSource, emptyTraceSource, errorsTraceSource, "default", false, false); string[] categories = new string[] { "newcat1", "newcat2" }; LogEntry logEntry = new LogEntry(); logEntry.Categories = categories; IEnumerable <LogSource> matchingTraceSources = logWriter.GetMatchingTraceSources(logEntry); logWriter.Dispose(); Dictionary <string, LogSource> matchingTraceSourcesDictionary = new Dictionary <string, LogSource>(); foreach (LogSource traceSource in matchingTraceSources) { matchingTraceSourcesDictionary.Add(traceSource.Name, traceSource); } Assert.AreEqual(2, matchingTraceSourcesDictionary.Count); Assert.AreEqual(0, ErrorsMockTraceListener.Entries.Count); }
public void CanFindMatchingCategories() { Dictionary <string, LogSource> traceSources = new Dictionary <string, LogSource>(); traceSources.Add("newcat1", new LogSource("newcat1")); traceSources.Add("newcat2", new LogSource("newcat2")); traceSources.Add("newcat3", new LogSource("newcat3")); traceSources.Add("newcat4", new LogSource("newcat4")); LogWriter logWriter = new LogWriterImpl(emptyFilters, traceSources, new LogSource("errors"), "default"); string[] categories = new string[] { "newcat1", "newcat2", "newcat5", "newcat6" }; LogEntry logEntry = new LogEntry(); logEntry.Categories = categories; IEnumerable <LogSource> matchingTraceSources = logWriter.GetMatchingTraceSources(logEntry); logWriter.Dispose(); Dictionary <string, LogSource> matchingTraceSourcesDictionary = new Dictionary <string, LogSource>(); foreach (LogSource traceSource in matchingTraceSources) { matchingTraceSourcesDictionary.Add(traceSource.Name, traceSource); } Assert.AreEqual(2, matchingTraceSourcesDictionary.Count); Assert.IsTrue(matchingTraceSourcesDictionary.ContainsKey(categories[0])); Assert.IsTrue(matchingTraceSourcesDictionary.ContainsKey(categories[1])); Assert.IsFalse(matchingTraceSourcesDictionary.ContainsKey(categories[2])); }
public void UsedMandatoryTraceSourceIfThereAreMatchingAndMissingCategories() { Dictionary <string, LogSource> traceSources = new Dictionary <string, LogSource>(); traceSources.Add("newcat1", new LogSource("newcat1")); traceSources.Add("newcat2", new LogSource("newcat2")); traceSources.Add("newcat3", new LogSource("newcat3")); traceSources.Add("newcat4", new LogSource("newcat4")); LogSource mandatoryTraceSource = new LogSource("mandatory"); LogSource errorsTraceSource = new LogSource("errors", SourceLevels.All); LogWriter logWriter = new LogWriterImpl(emptyFilters, traceSources, mandatoryTraceSource, emptyTraceSource, errorsTraceSource, "default", false, false); string[] categories = new string[] { "newcat1", "newcat2", "newcat5", "newcat6" }; LogEntry logEntry = new LogEntry(); logEntry.Categories = categories; IEnumerable <LogSource> matchingTraceSources = logWriter.GetMatchingTraceSources(logEntry); logWriter.Dispose(); Dictionary <string, LogSource> matchingTraceSourcesDictionary = new Dictionary <string, LogSource>(); foreach (LogSource traceSource in matchingTraceSources) { matchingTraceSourcesDictionary.Add(traceSource.Name, traceSource); } Assert.AreEqual(3, matchingTraceSourcesDictionary.Count); Assert.IsTrue(matchingTraceSourcesDictionary.ContainsKey(categories[0])); Assert.IsTrue(matchingTraceSourcesDictionary.ContainsKey(categories[1])); Assert.IsTrue(matchingTraceSourcesDictionary.ContainsKey(mandatoryTraceSource.Name)); Assert.AreEqual(0, ErrorsMockTraceListener.Entries.Count); }
public void ErrorWhileSendingToTraceSourceLogsWarningAndLogsOriginalMessageToNonFailingTraceSources() { LogSource errorsTraceSource = new LogSource("errors", SourceLevels.All); errorsTraceSource.Listeners.Add(new ErrorsMockTraceListener()); LogSource failingTraceSource = new LogSource("failing", SourceLevels.All); failingTraceSource.Listeners.Add(new ExceptionThrowingMockTraceListener()); LogSource loggingTraceSource = new LogSource("logging", SourceLevels.All); loggingTraceSource.Listeners.Add(new MockTraceListener()); LogWriter writer = new LogWriterImpl(new ILogFilter[0], new LogSource[] { failingTraceSource, loggingTraceSource }, errorsTraceSource, "default"); LogEntry logEntry = new LogEntry(); logEntry.Message = originalMessage; logEntry.Severity = TraceEventType.Critical; logEntry.Categories = new string[] { "failing", "logging" }; writer.Write(logEntry); writer.Dispose(); Assert.AreEqual(1, ErrorsMockTraceListener.Entries.Count); Assert.AreEqual(TraceEventType.Error, ErrorsMockTraceListener.LastEntry.Severity); Assert.IsTrue(MatchTemplate(ErrorsMockTraceListener.LastEntry.Message, Resources.TraceSourceFailed)); Assert.AreEqual(1, MockTraceListener.Entries.Count); Assert.AreSame(logEntry, MockTraceListener.LastEntry); }
public void NoErrorsWhileSendingToTraceSourceOnlyLogsOriginalMessageToCategoryTraceSources() { LogSource errorsTraceSource = new LogSource("errors", SourceLevels.All); errorsTraceSource.Listeners.Add(new ErrorsMockTraceListener()); LogSource failingTraceSource = new LogSource("logging", SourceLevels.All); failingTraceSource.Listeners.Add(new MockTraceListener()); LogSource loggingTraceSource = new LogSource("logging2", SourceLevels.All); loggingTraceSource.Listeners.Add(new MockTraceListener()); LogWriter writer = new LogWriterImpl(new ILogFilter[0], new LogSource[] { failingTraceSource, loggingTraceSource }, errorsTraceSource, "default"); LogEntry logEntry = new LogEntry(); logEntry.Message = originalMessage; logEntry.Severity = TraceEventType.Critical; logEntry.Categories = new string[] { "logging", "logging2" }; writer.Write(logEntry); writer.Dispose(); Assert.AreEqual(0, ErrorsMockTraceListener.Entries.Count); Assert.AreEqual(2, MockTraceListener.Entries.Count); Assert.AreSame(logEntry, MockTraceListener.LastEntry); }
public void PassingServiceLocatorForInstrumentationAndActivityIDProviderRequestsInstrumentationProviderInstance() { MockServiceLocator serviceLocator = new MockServiceLocator(); LogSource source = new LogSource("tracesource", SourceLevels.All); LogWriter logWriter = new LogWriterImpl(new List <ILogFilter>(), new List <LogSource>(), source, null, new LogSource("errors"), "default", false, false); new Tracer("testoperation", Guid.NewGuid(), logWriter, serviceLocator).Dispose(); Assert.AreEqual(1, serviceLocator.ServicesRequested.Count); Assert.AreEqual(typeof(ITracerInstrumentationProvider), serviceLocator.ServicesRequested[0]); }
private static TestEntLibLoggerFactoryAdapter CreateTestEntLibLoggerFactoryAdapter(ILogFilter filter) { LogWriter logWriter = new LogWriterImpl( new ILogFilter[] { filter } , new LogSource[] { new LogSource("logSource") } , new LogSource("defaultLogSource") , new LogSource("notProcessedLogSource") , new LogSource("errorsLogSource") , "DefaultCategory" , true , true ); return(new TestEntLibLoggerFactoryAdapter(5, EntLibLoggerSettings.DEFAULTEXCEPTIONFORMAT, logWriter)); }
private static TestEntLibLoggerFactoryAdapter CreateTestEntLibLoggerFactoryAdapter(ILogFilter filter) { LogWriter logWriter = new LogWriterImpl( new ILogFilter[] { filter } , new LogSource[] { new LogSource("logSource") } , new LogSource("defaultLogSource") , new LogSource("notProcessedLogSource") , new LogSource("errorsLogSource") , "DefaultCategory" , true , true ); return new TestEntLibLoggerFactoryAdapter(5, EntLibLoggerSettings.DEFAULTEXCEPTIONFORMAT, logWriter); }
public void UseTracingWithDisabledLoggerDoesntWrite() { MockTraceListener.Reset(); LogSource source = new LogSource("tracesource", SourceLevels.All); source.Listeners.Add(new MockTraceListener()); List <LogSource> traceSources = new List <LogSource>(new LogSource[] { source }); LogWriter logWriter = new LogWriterImpl(new List <ILogFilter>(), new List <LogSource>(), source, null, new LogSource("errors"), "default", false, false); using (Tracer tracer = new Tracer("testoperation", logWriter, (IConfigurationSource)null)) { Assert.AreEqual(0, MockTraceListener.Entries.Count); } Assert.AreEqual(0, MockTraceListener.Entries.Count); }
public void WhenChangeSourceIsInjectedOnLogWriter_ThenGetsRegisteredForChangeNotificationOnTheLoggingSettings() { var logWriter = new LogWriterImpl( new LogWriterStructureHolder( new ILogFilter[0], new Dictionary <string, LogSource>(), new LogSource(null), new LogSource(null), new LogSource(null), null, false, false, false), new LoggingInstrumentationProvider(false, false, null), coordinator); Assert.AreSame(logWriter, coordinator.AddedLoggingUpdateHandler); }
public void EventLogWrittenWhenDeliveryToErrorSourceFails() { TraceListener badTraceListener = new BadTraceListener(new Exception("test exception")); LogSource badSource = new LogSource("badSource"); badSource.Listeners.Add(badTraceListener); Dictionary <string, LogSource> logSources = new Dictionary <string, LogSource>(); logSources.Add("foo", badSource); ILoggingInstrumentationProvider instrumentationProvider = new LoggingInstrumentationProvider(false, true, "applicationInstanceName"); LogWriter writer = new LogWriterImpl(new List <ILogFilter>(), logSources, badSource, "foo", instrumentationProvider); writer.Write(CommonUtil.GetDefaultLogEntry()); string lastEventLogEntry = CommonUtil.GetLastEventLogEntry(); Assert.IsTrue(-1 != lastEventLogEntry.IndexOf("test exception")); }
public void GetTracerFromTraceManagerWithNoInstrumentation() { MockTraceListener.Reset(); LogSource source = new LogSource("tracesource", SourceLevels.All); source.Listeners.Add(new MockTraceListener()); List<LogSource> traceSources = new List<LogSource>(new LogSource[] { source }); LogWriter lg = new LogWriterImpl(new List<ILogFilter>(), new List<LogSource>(), source, null, new LogSource("errors"), "default", true, false); TraceManager tm = new TraceManager(lg); Assert.IsNotNull(tm); using (tm.StartTrace("testoperation")) { Assert.AreEqual(1, MockTraceListener.Entries.Count); } Assert.AreEqual(2, MockTraceListener.Entries.Count); }
public void GetTracerFromTraceManagerWithNoInstrumentation() { MockTraceListener.Reset(); LogSource source = new LogSource("tracesource", SourceLevels.All); source.Listeners.Add(new MockTraceListener()); List <LogSource> traceSources = new List <LogSource>(new LogSource[] { source }); LogWriter lg = new LogWriterImpl(new List <ILogFilter>(), new List <LogSource>(), source, null, new LogSource("errors"), "default", true, false); TraceManager tm = new TraceManager(lg); Assert.IsNotNull(tm); using (tm.StartTrace("testoperation")) { Assert.AreEqual(1, MockTraceListener.Entries.Count); } Assert.AreEqual(2, MockTraceListener.Entries.Count); }
public void MissingCategoriesWarningIsLoggedIfLogWarningFlagIsTrue() { LogSource errorsTraceSource = new LogSource("errors", SourceLevels.All); errorsTraceSource.Listeners.Add(new ErrorsMockTraceListener()); LogSource failingTraceSource = new LogSource("logging", SourceLevels.All); failingTraceSource.Listeners.Add(new MockTraceListener()); LogSource loggingTraceSource = new LogSource("logging2", SourceLevels.All); loggingTraceSource.Listeners.Add(new MockTraceListener()); LogWriter writer = new LogWriterImpl(new ILogFilter[0], new LogSource[] { failingTraceSource, loggingTraceSource }, emptyTraceSource, emptyTraceSource, errorsTraceSource, "default", false, true); LogEntry logEntry = new LogEntry(); logEntry.Message = originalMessage; logEntry.Severity = TraceEventType.Critical; logEntry.Categories = new string[] { "logging", "logging2", "logging3" }; writer.Write(logEntry); writer.Dispose(); Assert.AreEqual(1, ErrorsMockTraceListener.Entries.Count); Assert.AreEqual(TraceEventType.Error, ErrorsMockTraceListener.LastEntry.Severity); Assert.IsTrue(MatchTemplate(ErrorsMockTraceListener.LastEntry.Message, Resources.MissingCategories)); Assert.AreEqual(2, MockTraceListener.Entries.Count); Assert.AreSame(logEntry, MockTraceListener.LastEntry); }
public void CanGetLogFiltersByName() { ICollection <ILogFilter> filters = new List <ILogFilter>(); ICollection <string> categories = new List <string>(); categories.Add("cat1"); categories.Add("cat2"); categories.Add("cat3"); categories.Add("cat4"); filters.Add(new CategoryFilter("category", categories, CategoryFilterMode.AllowAllExceptDenied)); filters.Add(new PriorityFilter("priority1", 100)); filters.Add(new LogEnabledFilter("enable", true)); filters.Add(new PriorityFilter("priority2", 200)); LogWriter writer = new LogWriterImpl(filters, new Dictionary <string, LogSource>(), new LogSource("errors"), "default"); ILogFilter categoryFilter = writer.GetFilter("category"); ILogFilter priorityFilter = writer.GetFilter("priority2"); Assert.IsNotNull(categoryFilter); Assert.AreEqual(typeof(CategoryFilter), categoryFilter.GetType()); Assert.IsNotNull(priorityFilter); Assert.AreEqual(typeof(PriorityFilter), priorityFilter.GetType()); }
public void CanCreateLogWriterUsingConstructor() { LogWriter writer = new LogWriterImpl(new List<ILogFilter>(), new Dictionary<string, LogSource>(), new LogSource("errors"), "default"); }
public void CreationOfLogWriterUsingConstructorWithNullFiltersThrows() { LogWriter writer = new LogWriterImpl(null, new Dictionary<string, LogSource>(), new LogSource("errors"), "default"); }
protected override ILoggerFactoryAdapter GetLoggerFactoryAdapter() { LogWriter lw = new LogWriterImpl(new List<ILogFilter>(), new List<LogSource>(), new LogSource("errorSource"), "default"); return new EntLibLoggerFactoryAdapter(EntLibLoggerSettings.DEFAULTPRIORITY, EntLibLoggerSettings.DEFAULTEXCEPTIONFORMAT, lw); }
public void CreationOfLogWriterUsingConstructorWithNullFiltersThrows() { LogWriter writer = new LogWriterImpl(null, new Dictionary <string, LogSource>(), new LogSource("errors"), "default"); }
public void CanCreateLogWriterUsingConstructor() { LogWriter writer = new LogWriterImpl(new List <ILogFilter>(), new Dictionary <string, LogSource>(), new LogSource("errors"), "default"); }
public void CanGetLogFiltersByType() { ICollection<ILogFilter> filters = new List<ILogFilter>(); ICollection<string> categories = new List<string>(); categories.Add("cat1"); categories.Add("cat2"); categories.Add("cat3"); categories.Add("cat4"); filters.Add(new CategoryFilter("category", categories, CategoryFilterMode.AllowAllExceptDenied)); filters.Add(new PriorityFilter("priority", 100)); filters.Add(new LogEnabledFilter("enable", true)); LogWriter writer = new LogWriterImpl(filters, new Dictionary<string, LogSource>(), new LogSource("errors"), "default"); CategoryFilter categoryFilter = writer.GetFilter<CategoryFilter>(); PriorityFilter priorityFilter = writer.GetFilter<PriorityFilter>(); LogEnabledFilter enabledFilter = writer.GetFilter<LogEnabledFilter>(); Assert.IsNotNull(categoryFilter); Assert.AreEqual(4, categoryFilter.CategoryFilters.Count); Assert.IsNotNull(priorityFilter); Assert.AreEqual(100, priorityFilter.MinimumPriority); Assert.IsNotNull(enabledFilter); Assert.IsTrue(enabledFilter.Enabled); }
public void UsesDefaultTraceSourceIfThereAreMissingCategoriesAndDefaultIsConfiguredAndMandatoryIsNotConfigured() { Dictionary<string, LogSource> traceSources = new Dictionary<string, LogSource>(); traceSources.Add("newcat1", new LogSource("newcat1")); traceSources.Add("newcat2", new LogSource("newcat2")); traceSources.Add("newcat3", new LogSource("newcat3")); traceSources.Add("newcat4", new LogSource("newcat4")); LogSource mandatoryTraceSource = null; LogSource defaultTraceSource = new LogSource("default"); LogSource errorsTraceSource = new LogSource("errors", SourceLevels.All); errorsTraceSource.Listeners.Add(new ErrorsMockTraceListener()); LogWriter logWriter = new LogWriterImpl(emptyFilters, traceSources, mandatoryTraceSource, defaultTraceSource, errorsTraceSource, "default", false, false); string[] categories = new string[] { "newcat1", "newcat2", "newcat5", "newcat6" }; LogEntry logEntry = new LogEntry(); logEntry.Categories = categories; IEnumerable<LogSource> matchingTraceSources = logWriter.GetMatchingTraceSources(logEntry); logWriter.Dispose(); Dictionary<string, LogSource> matchingTraceSourcesDictionary = new Dictionary<string, LogSource>(); foreach (LogSource traceSource in matchingTraceSources) { matchingTraceSourcesDictionary.Add(traceSource.Name, traceSource); } Assert.AreEqual(3, matchingTraceSourcesDictionary.Count); Assert.IsTrue(matchingTraceSourcesDictionary.ContainsKey(categories[0])); Assert.IsTrue(matchingTraceSourcesDictionary.ContainsKey(categories[1])); Assert.IsTrue(matchingTraceSourcesDictionary.ContainsKey(defaultTraceSource.Name)); Assert.AreEqual(0, ErrorsMockTraceListener.Entries.Count); }
public void DoesNotReportMissingCategoriesWhenThereAreNotMissingCategoriesAndDefaultIsNotConfigured() { Dictionary<string, LogSource> traceSources = new Dictionary<string, LogSource>(); traceSources.Add("newcat1", new LogSource("newcat1")); traceSources.Add("newcat2", new LogSource("newcat2")); traceSources.Add("newcat3", new LogSource("newcat3")); traceSources.Add("newcat4", new LogSource("newcat4")); LogSource errorsTraceSource = new LogSource("errors", SourceLevels.All); errorsTraceSource.Listeners.Add(new ErrorsMockTraceListener()); LogWriter logWriter = new LogWriterImpl(emptyFilters, traceSources, emptyTraceSource, emptyTraceSource, errorsTraceSource, "default", false, false); string[] categories = new string[] { "newcat1", "newcat2" }; LogEntry logEntry = new LogEntry(); logEntry.Categories = categories; IEnumerable<LogSource> matchingTraceSources = logWriter.GetMatchingTraceSources(logEntry); logWriter.Dispose(); Dictionary<string, LogSource> matchingTraceSourcesDictionary = new Dictionary<string, LogSource>(); foreach (LogSource traceSource in matchingTraceSources) { matchingTraceSourcesDictionary.Add(traceSource.Name, traceSource); } Assert.AreEqual(2, matchingTraceSourcesDictionary.Count); Assert.AreEqual(0, ErrorsMockTraceListener.Entries.Count); }
public void CanFindMatchingCategories() { Dictionary<string, LogSource> traceSources = new Dictionary<string, LogSource>(); traceSources.Add("newcat1", new LogSource("newcat1")); traceSources.Add("newcat2", new LogSource("newcat2")); traceSources.Add("newcat3", new LogSource("newcat3")); traceSources.Add("newcat4", new LogSource("newcat4")); LogWriter logWriter = new LogWriterImpl(emptyFilters, traceSources, new LogSource("errors"), "default"); string[] categories = new string[] { "newcat1", "newcat2", "newcat5", "newcat6" }; LogEntry logEntry = new LogEntry(); logEntry.Categories = categories; IEnumerable<LogSource> matchingTraceSources = logWriter.GetMatchingTraceSources(logEntry); logWriter.Dispose(); Dictionary<string, LogSource> matchingTraceSourcesDictionary = new Dictionary<string, LogSource>(); foreach (LogSource traceSource in matchingTraceSources) { matchingTraceSourcesDictionary.Add(traceSource.Name, traceSource); } Assert.AreEqual(2, matchingTraceSourcesDictionary.Count); Assert.IsTrue(matchingTraceSourcesDictionary.ContainsKey(categories[0])); Assert.IsTrue(matchingTraceSourcesDictionary.ContainsKey(categories[1])); Assert.IsFalse(matchingTraceSourcesDictionary.ContainsKey(categories[2])); }
public void CreationOfLogWriterUsingConstructorWithNullTraceSourcesThrows() { LogWriter writer = new LogWriterImpl(new List <ILogFilter>(), (IDictionary <string, LogSource>)null, new LogSource("errors"), "default"); }
public void CreationOfLogWriterUsingConstructorWithNullErrorsTraceSourceThrows() { LogWriter writer = new LogWriterImpl(new List <ILogFilter>(), new Dictionary <string, LogSource>(), null, "default"); }
public void CreationOfLogWriterUsingConstructorWithNullTraceSourcesThrows() { LogWriter writer = new LogWriterImpl(new List<ILogFilter>(), (IDictionary<string, LogSource>)null, new LogSource("errors"), "default"); }
public void CanGetLogFiltersByName() { ICollection<ILogFilter> filters = new List<ILogFilter>(); ICollection<string> categories = new List<string>(); categories.Add("cat1"); categories.Add("cat2"); categories.Add("cat3"); categories.Add("cat4"); filters.Add(new CategoryFilter("category", categories, CategoryFilterMode.AllowAllExceptDenied)); filters.Add(new PriorityFilter("priority1", 100)); filters.Add(new LogEnabledFilter("enable", true)); filters.Add(new PriorityFilter("priority2", 200)); LogWriter writer = new LogWriterImpl(filters, new Dictionary<string, LogSource>(), new LogSource("errors"), "default"); ILogFilter categoryFilter = writer.GetFilter("category"); ILogFilter priorityFilter = writer.GetFilter("priority2"); Assert.IsNotNull(categoryFilter); Assert.AreEqual(typeof(CategoryFilter), categoryFilter.GetType()); Assert.IsNotNull(priorityFilter); Assert.AreEqual(typeof(PriorityFilter), priorityFilter.GetType()); }
public void EventLogWrittenWhenDeliveryToErrorSourceFails() { TraceListener badTraceListener = new BadTraceListener(new Exception("test exception")); LogSource badSource = new LogSource("badSource"); badSource.Listeners.Add(badTraceListener); Dictionary<string, LogSource> logSources = new Dictionary<string, LogSource>(); logSources.Add("foo", badSource); ILoggingInstrumentationProvider instrumentationProvider = new LoggingInstrumentationProvider(false, true, "applicationInstanceName"); LogWriter writer = new LogWriterImpl(new List<ILogFilter>(), logSources, badSource, "foo", instrumentationProvider); writer.Write(CommonUtil.GetDefaultLogEntry()); string lastEventLogEntry = CommonUtil.GetLastEventLogEntry(); Assert.IsTrue(-1 != lastEventLogEntry.IndexOf("test exception")); }
public void CreationOfLogWriterUsingConstructorWithNullErrorsTraceSourceThrows() { LogWriter writer = new LogWriterImpl(new List<ILogFilter>(), new Dictionary<string, LogSource>(), null, "default"); }
protected override ILoggerFactoryAdapter GetLoggerFactoryAdapter() { LogWriter lw = new LogWriterImpl(new List <ILogFilter>(), new List <LogSource>(), new LogSource("errorSource"), "default"); return(new EntLibLoggerFactoryAdapter(EntLibLoggerSettings.DEFAULTPRIORITY, EntLibLoggerSettings.DEFAULTEXCEPTIONFORMAT, lw)); }