Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class MonitoringTestExecutionTests

public MonitoringTestExecutionTests()
{
Formatter<TraceBuffer>.Register(b => new
LogFormatter<TraceBuffer>.Register(b => new
{
b.HasContent,
HashCode = b.GetHashCode()
Expand Down
10 changes: 5 additions & 5 deletions Its.Log.Monitoring/AssertionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ public static class AssertionExtensions
{
static AssertionExtensions()
{
Formatter<ObjectContent>.RegisterForAllMembers();
Formatter<StringContent>.Register(c => new
LogFormatter<ObjectContent>.RegisterForAllMembers();
LogFormatter<StringContent>.Register(c => new
{
c.ReadAsStringAsync().Result,
c.Headers
}.ToLogString());
Formatter<StreamContent>.Register(c => new
LogFormatter<StreamContent>.Register(c => new
{
c.ReadAsStringAsync().Result,
c.Headers
}.ToLogString());
Formatter<HttpContentHeaders>.RegisterForAllMembers();
Formatter<HttpError>.RegisterForAllMembers();
LogFormatter<HttpContentHeaders>.RegisterForAllMembers();
LogFormatter<HttpError>.RegisterForAllMembers();
}

public static HttpResponseMessage ShouldSucceed(
Expand Down
2 changes: 1 addition & 1 deletion Its.Log.Monitoring/TestTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class TestTarget
{
static TestTarget()
{
Formatter<TestTarget>.RegisterForAllMembers();
LogFormatter<TestTarget>.RegisterForAllMembers();
}

internal TestTarget()
Expand Down
46 changes: 23 additions & 23 deletions Its.Log.UnitTests/Demo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ public void Basics3_You_control_where_entries_get_written()
public void Formatting1_Format_the_log_output_so_that_it_is_more_descriptive()
{
Log.EntryPosted += (sender, e) => Console.WriteLine(e.LogEntry.ToLogString());
Formatter<Movie>.RegisterForAllMembers();
Formatter<Person>.RegisterForAllMembers();
LogFormatter<Movie>.RegisterForAllMembers();
LogFormatter<Person>.RegisterForAllMembers();

Log.Write(() => Movie.StarWars);
}
Expand All @@ -71,10 +71,10 @@ public void Formatting2_Format_the_log_output_so_that_it_not_tooooo_descriptive(
Log.EntryPosted += (sender, e) => Console.WriteLine(e.LogEntry.ToLogString());

// only certain properties...
Formatter<Movie>.RegisterForMembers(m => m.Title, m => m.Stars);
LogFormatter<Movie>.RegisterForMembers(m => m.Title, m => m.Stars);

// or specify your own function...
Formatter<Person>.Register(p => string.Format("{0} (born: {1})", p.Name, p.DateOfBirth));
LogFormatter<Person>.Register(p => string.Format("{0} (born: {1})", p.Name, p.DateOfBirth));

Log.Write(() => Movie.StarWars);
}
Expand Down Expand Up @@ -104,10 +104,10 @@ public void Formatting4_Every_exception_gets_an_unique_id_which_is_shared_among_
Log.EntryPosted += (sender, e) => Console.WriteLine(e.LogEntry.ToLogString());

// scope down the formatting to show just the relevant bits
Formatter<LogEntry>.RegisterForMembers(e => e.ExceptionId, e => e.EventType, e => e.Subject);
Formatter<DataException>.RegisterForMembers(e => e.Data, e => e.InnerException);
Formatter<NullReferenceException>.RegisterForMembers(e => e.Data, e => e.InnerException);
Formatter<InvalidOperationException>.RegisterForMembers(e => e.Data, e => e.InnerException);
LogFormatter<LogEntry>.RegisterForMembers(e => e.ExceptionId, e => e.EventType, e => e.Subject);
LogFormatter<DataException>.RegisterForMembers(e => e.Data, e => e.InnerException);
LogFormatter<NullReferenceException>.RegisterForMembers(e => e.Data, e => e.InnerException);
LogFormatter<InvalidOperationException>.RegisterForMembers(e => e.Data, e => e.InnerException);
;

var dataException = new DataException("oops!");
Expand All @@ -129,8 +129,8 @@ public void Formatting4_Every_exception_gets_an_unique_id_which_is_shared_among_
public void Formatting5_Logging_several_objects()
{
Log.EntryPosted += (sender, e) => Console.WriteLine(e.LogEntry.ToLogString());
Formatter<Movie>.RegisterForAllMembers();
Formatter<Person>.RegisterForAllMembers();
LogFormatter<Movie>.RegisterForAllMembers();
LogFormatter<Person>.RegisterForAllMembers();

var carrie = Person.CarrieFisher;
Log.Write(() => new { carrie, Person.GeorgeLucas });
Expand All @@ -140,30 +140,30 @@ public void Formatting5_Logging_several_objects()
public void Formatting6_What_about_long_lists()
{
Log.EntryPosted += (sender, e) => Console.WriteLine(e.LogEntry.ToLogString());
Formatter<Movie>.RegisterForAllMembers();
Formatter<Person>.RegisterForAllMembers();
LogFormatter<Movie>.RegisterForAllMembers();
LogFormatter<Person>.RegisterForAllMembers();

Formatter.ListExpansionLimit = 5;
LogFormatter.ListExpansionLimit = 5;
Log.Write(() => Movie.StarWars);

Formatter.ListExpansionLimit = 10;
LogFormatter.ListExpansionLimit = 10;
Log.Write(() => Movie.StarWars);
}

[Test]
public void Formatting8_What_about_recursion()
{
Log.EntryPosted += (sender, e) => Console.WriteLine(e.LogEntry.ToLogString());
Formatter<Movie>.RegisterForAllMembers();
Formatter<Person>.RegisterForAllMembers();
LogFormatter<Movie>.RegisterForAllMembers();
LogFormatter<Person>.RegisterForAllMembers();

// set up a recursive relationship that the above properties formatters will traverse
Person.GeorgeLucas.Movies = new[] { Movie.StarWars };

Formatter.RecursionLimit = 3;
LogFormatter.RecursionLimit = 3;
Log.Write(() => Person.GeorgeLucas);

Formatter.RecursionLimit = 10;
LogFormatter.RecursionLimit = 10;
Log.Write(() => Person.GeorgeLucas);
}

Expand All @@ -183,7 +183,7 @@ public void LogEntryObject2_Has_information_about_the_call_source()
Log.EntryPosted += (sender, e) => Console.WriteLine(e.LogEntry.ToLogString());

// this is already in the default output, but it's also in the LogEntry object, so we'll create a formatter that exposes it directly
Formatter<LogEntry>.RegisterForMembers(
LogFormatter<LogEntry>.RegisterForMembers(
e => e.CallingType,
e => e.CallingMethod);

Expand All @@ -195,7 +195,7 @@ public void LogEntryObject3_Has_a_time_stamp()
{
Log.EntryPosted += (sender, e) => Console.WriteLine(e.LogEntry.ToLogString());

Formatter<LogEntry>.RegisterForMembers(e => e.TimeStamp);
LogFormatter<LogEntry>.RegisterForMembers(e => e.TimeStamp);

Log.Write(() => new { Person.GeorgeLucas });
}
Expand All @@ -205,7 +205,7 @@ public void LogEntryObject4_Has_a_unique_exception_id_if_the_subject_is_an_excep
{
Log.EntryPosted += (sender, e) => Console.WriteLine(e.LogEntry.ToLogString());

Formatter<LogEntry>.RegisterForMembers(e => e.ExceptionId);
LogFormatter<LogEntry>.RegisterForMembers(e => e.ExceptionId);

Log.Write(() => new { Person.GeorgeLucas });
Log.Write(() => new Exception("oops"));
Expand All @@ -217,7 +217,7 @@ public void MethodBoundaries1_Logging_method_boundaries()
Log.EntryPosted += (sender, e) => Console.WriteLine(e.LogEntry.ToLogString());

// again, isolating just the parts that are specific to boundary logging:
Formatter<LogEntry>.RegisterForMembers(
LogFormatter<LogEntry>.RegisterForMembers(
e => e.Message,
e => e.Params,
e => e.ElapsedMilliseconds);
Expand Down Expand Up @@ -366,7 +366,7 @@ public void Reactive4_Disable_logging_from_specific_classes()
public void SetUp()
{
Log.UnsubscribeAllFromEntryPosted();
Formatter.ResetToDefault();
LogFormatter.ResetToDefault();
Extension.EnableAll();
}
}
Expand Down
4 changes: 2 additions & 2 deletions Its.Log.UnitTests/ExtensionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,11 @@ public void Params_usage_of_formatter_for_ToString_does_not_cause_stack_overflow
var count = 0;
for (var i = 1; i <= 20; i++)
{
Formatter.RecursionLimit = i;
LogFormatter.RecursionLimit = i;
using (TestHelper.LogToConsole())
using (Log.Events().Subscribe(e => count++))
{
Log.WithParams(() => new { Formatter.RecursionLimit }).Write("testing...");
Log.WithParams(() => new { LogFormatter.RecursionLimit }).Write("testing...");
}
}

Expand Down
Loading