public void Log_events_emitted_by_regular_Loggers_within_the_scope_of_an_operation_bear_the_id_of_the_ambient_operation() { var log = new LogEntryList(); using (Subscribe(log.Add)) using (Log.OnEnterAndExit()) { Log.Info("hello"); } log.Select(e => e.Operation.Id).Distinct().Should().HaveCount(1); }
public void Log_events_within_an_operation_share_an_id() { var log = new LogEntryList(); using (Subscribe(log.Add)) using (var operation = Log.OnEnterAndExit()) { operation.Info("hello"); } log.Select(e => e.Operation.Id).Distinct().Should().HaveCount(1); }
public void TestStartEndTimestamp1() { var content = new LogEntryList(LogFileColumns.Timestamp); content.Add(new LogEntry2 { Timestamp = new DateTime(2017, 12, 21, 14, 11, 0) }); var logFile = CreateFromContent(content); logFile.GetValue(LogFileProperties.StartTimestamp).Should().Be(new DateTime(2017, 12, 21, 14, 11, 0)); logFile.GetValue(LogFileProperties.EndTimestamp).Should().Be(new DateTime(2017, 12, 21, 14, 11, 0)); }
public void Using_static_can_be_used_to_specify_a_log_category_for_the_whole_file() { var log = new LogEntryList(); using (Subscribe(log.Add)) { Log.Info("hi!"); } log.Should() .Contain(e => e.Category == typeof(LoggerUsingStaticLogCategorizationTests).FullName); }
public void Exceptions_can_be_written_at_Warning_level() { var log = new LogEntryList(); using (Subscribe(log.Add)) { Log.Warning(new Exception("oops")); } log.Single().LogLevel.Should().Be((int)LogLevel.Warning); log.Single().Exception.Should().NotBeNull(); }
//get bucket by name and create the bucket if not in loan already. private TrackedDocument getBucket(string bucketTitle) { LogEntryList findings = EncompassApplication.CurrentLoan.Log.TrackedDocuments.GetDocumentsByTitle(bucketTitle); if (findings.Count < 1) { EncompassApplication.CurrentLoan.Log.TrackedDocuments.Add(bucketTitle, "Submittal"); findings = EncompassApplication.CurrentLoan.Log.TrackedDocuments.GetDocumentsByTitle(bucketTitle); } return((TrackedDocument)findings[0]); }
public void Log_OnEnterAndExit_logs_a_Start_event_on_enter_and_a_Stop_event_on_exit() { var log = new LogEntryList(); using (Subscribe(log.Add)) using (Log.OnEnterAndExit()) { } log.Should().HaveCount(2); log[0].Operation.IsEnd.Should().BeFalse(); log[1].Operation.IsSuccessful.Should().BeNull(); }
public void Log_OnExit_logs_a_Stop_event_on_exit() { var log = new LogEntryList(); using (Subscribe(log.Add)) using (Log.OnExit()) { } log.Should().HaveCount(1); log.Last().Operation.IsEnd.Should().BeTrue(); log.Last().Operation.IsSuccessful.Should().BeNull(); }
public void After_Dispose_is_called_then_an_OperationLogger_does_not_log_again() { var log = new LogEntryList(); using (Subscribe(log.Add)) using (var operation = Log.OnExit()) { operation.Dispose(); operation.Info("hello"); } log.Count.Should().Be(1); }
public void TestRemoveRangeInvalidIndex2([Values(3, 42)] int invalidIndex) { var entries = new LogEntryList(LogFileColumns.RawContent); entries.Add("foo"); entries.Add("bar"); entries.Count.Should().Be(2); new Action(() => entries.RemoveRange(invalidIndex, 1)).Should().Throw <ArgumentException>(); entries.Count.Should().Be(2); entries[0].RawContent.Should().Be("foo"); entries[1].RawContent.Should().Be("bar"); }
public void When_logger_discovery_specifies_the_same_assembly_more_than_once_it_is_only_subscribed_once() { var log = new LogEntryList(); using (Subscribe( log.Add, new[] { typeof(Class1).Assembly, typeof(Class1).Assembly })) { Class1.EmitSomeLogEvents(); } log.Count.Should().Be(3, $"{nameof(Class1.EmitSomeLogEvents)} writes 3 log events."); }
public void When_confirmation_is_required_then_it_logs_a_successful_result_when_completed() { var log = new LogEntryList(); using (Subscribe(log.Add)) using (var operation = Log.OnEnterAndConfirmOnExit()) { operation.Succeed(); } log.Last().Operation.IsEnd.Should().BeTrue(); log.Last().Operation.IsSuccessful.Should().BeTrue(); }
public void When_confirmation_is_required_then_it_logs_an_unsuccessful_result_when_not_confirmed() { var log = new LogEntryList(); using (Subscribe(log.Add)) using (Log.OnEnterAndConfirmOnExit()) { // don't call Fail or Succeed } log.Last().Operation.IsEnd.Should().BeTrue(); log.Last().Operation.IsSuccessful.Should().BeFalse(); }
public void Further_log_entries_are_not_received_after_disposing_the_subscription() { var log = new LogEntryList(); using (Subscribe(log.Add)) { } Log.Info("hello"); log.Should() .BeEmpty(); }
public void After_Fail_is_called_then_a_ConfirmationLogger_does_not_log_on_dispose() { var log = new LogEntryList(); using (Subscribe(log.Add)) using (var operation = Log.ConfirmOnExit()) { operation.Fail(message: "Oops! {0}", args: "bye!"); operation.Info("hello"); } log.Last().Evaluate().Message.Should().Be("hello"); }
public void Logger_T_captures_a_category_based_on_type_T() { var logger = new Logger <LoggerTests>(); var log = new LogEntryList(); using (Subscribe(log.Add)) { logger.Info("hello"); } log.Should().Contain(e => e.Category == typeof(LoggerTests).FullName); }
public async Task It_records_timings_for_checkpoints() { var log = new LogEntryList(); using (Subscribe(log.Add)) using (Log.OnEnterAndExit()) { await Task.Delay(250); } log[0].Operation.Duration?.TotalMilliseconds.Should().BeInRange(0, 50); log[1].Operation.Duration?.TotalMilliseconds.Should().BeGreaterOrEqualTo(200); }
public void By_befault_an_operation_has_no_category() { var log = new LogEntryList(); using (Subscribe(log.Add)) using (var operation1 = Log.OnExit()) using (var operation2 = Log.OnEnterAndExit()) { operation1.Info("hello"); operation2.Info("hello"); } log.Should().OnlyContain(e => e.Category == ""); }
public async Task Loggers_in_referenced_assemblies_can_be_discovered_and_subscribed() { var log = new LogEntryList(); var message = $"hello from {nameof(Loggers_in_referenced_assemblies_can_be_discovered_and_subscribed)}"; using (Subscribe(log.Add)) { Class1.EmitSomeLogEvents(message); await Task.Delay(100); } log.Should().Contain(e => e.ToLogString().Contains(message)); }
public void TestRemoveAtInvalidIndex([Values(-1, 1, 2)] int invalidIndex) { var entries = new LogEntryList(LogFileColumns.DeltaTime, LogFileColumns.RawContent); entries.Add(TimeSpan.FromSeconds(44), "stuff"); entries.Count.Should().Be(1); entries[0].DeltaTime.Should().Be(TimeSpan.FromSeconds(44)); entries[0].RawContent.Should().Be("stuff"); new Action(() => entries.RemoveAt(invalidIndex)).Should().Throw <ArgumentOutOfRangeException>(); entries.Count.Should().Be(1); entries[0].DeltaTime.Should().Be(TimeSpan.FromSeconds(44)); entries[0].RawContent.Should().Be("stuff"); }
protected override IReadOnlyLogEntries Create(IEnumerable <IReadOnlyLogEntry> entries) { if (entries.Any()) { var list = new LogEntryList(entries.First().Columns); foreach (var entry in entries) { list.Add(entry); } return(list); } return(CreateEmpty(new ILogFileColumn[0])); }
public void When_exceptions_are_logged_then_the_message_contains_the_exception_details() { var log = new LogEntryList(); var exception = new Exception("oops!"); using (Subscribe(log.Add)) { Log.Error("oh no!", exception); } log.Single() .ToString() .Should() .Contain(exception.ToString()); }
public void Subscribe_allows_all_log_events_to_be_monitored() { var log = new LogEntryList(); using (Subscribe(log.Add)) { Log.Info("hello"); } log.Should() .ContainSingle(e => e.Evaluate() .Message .Contains("hello")); }
public void When_no_confirmation_is_required_then_IsOperationSuccessful_is_null() { var log = new LogEntryList(); using (Subscribe(e => log.Add(e))) using (Log.OnExit()) { } log.Single() .Operation .IsSuccessful .Should() .BeNull(); }
private List <Attachment> GetAttachmentForEachBorrowerPair(Loan loan, string trackedDocument) { List <Attachment> attachments = new List <Attachment>(); LogEntryList trackedDocuments = loan.Log.TrackedDocuments.GetDocumentsByTitle(trackedDocument); foreach (TrackedDocument doc in trackedDocuments) { AttachmentList attList = doc.GetAttachments(); foreach (Attachment att in attList) { attachments.Add(att); } } return(attachments); }
public async Task Loggers_in_referenced_assemblies_can_be_unsubscribed() { var log = new LogEntryList(); using (Subscribe(log.Add)) { Class1.EmitSomeLogEvents($"before unsubscribe"); await Task.Delay(100); } Class1.EmitSomeLogEvents($"after unsubscribe"); log.Should().Contain(e => e.ToLogString().Contains("before unsubscribe")); log.Should().NotContain(e => e.ToLogString().Contains("after unsubscribe")); }
public void Log_entries_within_an_operation_contain_their_id_in_string_output() { var log = new LogEntryList(); string operationId; using (Subscribe(log.Add)) using (var operation = Log.OnEnterAndExit()) { operationId = operation.Id; operation.Info("hello"); } log.Should().OnlyContain(e => e.ToString().Contains(operationId)); }
public void When_exceptions_are_logged_then_they_are_accessible_on_the_LogEntry() { var log = new LogEntryList(); var exception = new Exception("oops!"); using (Subscribe(log.Add)) { Log.Error("oh no!", exception); } log.Single() .Exception .Should() .Be(exception); }
public void TestClearMany() { var entries = new LogEntryList(LogFileColumns.LineNumber); entries.Add(42); entries.Add(9001); entries.Count.Should().Be(2); entries.Clear(); entries.Count.Should().Be(0); entries.AddEmpty(); entries.AddEmpty(); entries.Count.Should().Be(2); entries[0].LineNumber.Should().Be(0); entries[1].LineNumber.Should().Be(0); }
public void TestAddManyEntries() { const int count = 101; var entries = new LogEntryList(LogFileColumns.Index, LogFileColumns.RawContent); for (int i = 0; i < count; ++i) { entries.Add(new LogLineIndex(i), i.ToString()); entries.Count.Should().Be(i + 1); } for (int i = 0; i < count; ++i) { entries[i].Index.Should().Be(i); entries[i].RawContent.Should().Be(i.ToString()); } }
private void logEntryList_NewEntry(object sender, LogEntryList.ViewEntryEventArgs e) { DataLogOutput.LogEntry logEntry = e.Entry.LogEntry; bool isHidden = this.DockHandler.DockState.IsAutoHide() && !this.ContainsFocus; bool unseenChanges = false; if (isHidden) { if (logEntry.Type == LogMessageType.Warning) { this.unseenWarnings++; unseenChanges = true; } else if (logEntry.Type == LogMessageType.Error) { if (this.unseenErrors == 0) System.Media.SystemSounds.Hand.Play(); this.unseenErrors++; unseenChanges = true; } } if (unseenChanges) this.UpdateTabText(); }
public ViewEntry(LogEntryList parent, LogEntry log) { this.log = log; this.msgLines = log.Message.Split(new string[] { Environment.NewLine }, StringSplitOptions.None).Length; this.height = Math.Max(20, 7 + this.msgLines * parent.Font.Height); }