Skip to content

Commit 71dbf87

Browse files
committed
Switched the "DebugTarget" to be a "TraceTarget", because the "DebugTarget" doesn't write if compiled in a Release build - tests were failing, and, a DebugTarget isn't that useful in "live" code, so it wasn't helpful, anyways.
1 parent 68d6fbd commit 71dbf87

6 files changed

Lines changed: 28 additions & 30 deletions

File tree

Take2/NuLog.Tests/Integration/Factories/StandardLoggerFactoryIntegrationTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public void Should_UseTargetsAndBuildTagRouter()
135135
var targetConfig = new TargetConfig
136136
{
137137
Name = "debug",
138-
Type = "NuLog.Targets.DebugTarget",
138+
Type = "NuLog.Targets.TraceTarget",
139139
Properties = new Dictionary<string, object>
140140
{
141141
{ "layout", "${Message}" }
@@ -233,7 +233,7 @@ public void Should_SetDispatcherToNewLogger()
233233
new TargetConfig
234234
{
235235
Name = "debug",
236-
Type = "NuLog.Targets.DebugTarget",
236+
Type = "NuLog.Targets.TraceTarget",
237237
Properties = new Dictionary<string, object>
238238
{
239239
{ "layout", "${Message}" }
@@ -273,7 +273,7 @@ public void Should_SetMetaDataProviderToNewLogger()
273273
new TargetConfig
274274
{
275275
Name = "debug",
276-
Type = "NuLog.Targets.DebugTarget",
276+
Type = "NuLog.Targets.TraceTarget",
277277
Properties = new Dictionary<string, object>
278278
{
279279
{ "layout", "${MyMetaData}" }
@@ -317,7 +317,7 @@ public void Should_SetDefaultTagsToNewLogger()
317317
new TargetConfig
318318
{
319319
Name = "debug",
320-
Type = "NuLog.Targets.DebugTarget",
320+
Type = "NuLog.Targets.TraceTarget",
321321
Properties = new Dictionary<string, object>
322322
{
323323
{ "layout", "${Tags}" }
@@ -357,7 +357,7 @@ public void Should_SetDefaultMetaDataToNewLogger()
357357
new TargetConfig
358358
{
359359
Name = "debug",
360-
Type = "NuLog.Targets.DebugTarget",
360+
Type = "NuLog.Targets.TraceTarget",
361361
Properties = new Dictionary<string, object>
362362
{
363363
{ "layout", "${MyMetaData}" }

Take2/NuLog.Tests/NuLog.Tests.csproj

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,11 @@
110110
<Compile Include="Unit\TagRouters\RuleProcessors\RuleProcessorIncludeRulesTests.cs" />
111111
<Compile Include="Unit\TagRouters\RuleProcessors\RuleProcessorTestsBase.cs" />
112112
<Compile Include="Unit\TagRouters\TagGroupProcessors\TagGroupProcessorTests.cs" />
113-
<Compile Include="Unit\Targets\DebugTargetTests.cs" />
113+
<Compile Include="Unit\Targets\TraceTargetTests.cs" />
114114
<Compile Include="Unit\Targets\LayoutTargetBaseTests.cs" />
115115
<Compile Include="Unit\Targets\TextFileTargetTests.cs" />
116116
</ItemGroup>
117-
<ItemGroup>
118-
<Folder Include="Integration\Targets\" />
119-
</ItemGroup>
117+
<ItemGroup />
120118
<ItemGroup>
121119
<None Include="App.config">
122120
<SubType>Designer</SubType>

Take2/NuLog.Tests/Unit/Factories/StandardLoggerFactoryUnitTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public void Should_CreateMultipleTargets()
196196
},new TargetConfig
197197
{
198198
Name = "dummy",
199-
Type = "NuLog.Targets.DebugTarget, NuLog"
199+
Type = "NuLog.Targets.TraceTarget, NuLog"
200200
}
201201
};
202202
var config = new Config
@@ -211,7 +211,7 @@ public void Should_CreateMultipleTargets()
211211
// Validate
212212
Assert.Equal(2, targets.Count);
213213
Assert.True(targets.Any(t => typeof(DummyTarget).IsAssignableFrom(t.GetType())));
214-
Assert.True(targets.Any(t => typeof(DebugTarget).IsAssignableFrom(t.GetType())));
214+
Assert.True(targets.Any(t => typeof(TraceTarget).IsAssignableFrom(t.GetType())));
215215
}
216216

217217
/// <summary>

Take2/NuLog.Tests/Unit/Targets/DebugTargetTests.cs renamed to Take2/NuLog.Tests/Unit/Targets/TraceTargetTests.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,59 +12,59 @@
1212
namespace NuLog.Tests.Unit.Targets
1313
{
1414
/// <summary>
15-
/// Documents (and verifies) the expected behavior of the debug target.
15+
/// Documents (and verifies) the expected behavior of the trace target.
1616
/// </summary>
1717
[Trait("Category", "Unit")]
18-
public class DebugTargetTests : IDisposable
18+
public class TraceTargetTests : IDisposable
1919
{
2020
private HashSetTraceListener traceListener;
2121

22-
public DebugTargetTests()
22+
public TraceTargetTests()
2323
{
2424
this.traceListener = new HashSetTraceListener();
25-
Debug.Listeners.Add(this.traceListener);
25+
Trace.Listeners.Add(this.traceListener);
2626
}
2727

2828
public void Dispose()
2929
{
30-
Debug.Listeners.Remove(this.traceListener);
30+
Trace.Listeners.Remove(this.traceListener);
3131
this.traceListener = null;
3232
}
3333

3434
/// <summary>
35-
/// The debug target should write to debug.
35+
/// The trace target should write to trace.
3636
/// </summary>
37-
[Fact(DisplayName = "Should_WriteToDebug")]
38-
public void Should_WriteToDebug()
37+
[Fact(DisplayName = "Should_WriteToTrace")]
38+
public void Should_WriteToTrace()
3939
{
4040
// Setup
4141
var logEvent = new LogEvent
4242
{
43-
Message = "Should_WriteToDebug - hello, world!"
43+
Message = "Should_WriteToTrace - hello, world!"
4444
};
4545
var layout = A.Fake<ILayout>();
4646
A.CallTo(() => layout.Format(A<LogEvent>.Ignored)).Returns(logEvent.Message);
4747

48-
var target = new DebugTarget();
48+
var target = new TraceTarget();
4949
target.SetLayout(layout);
5050

5151
// Execute
5252
target.Write(logEvent);
5353

5454
// Verify
55-
Assert.Contains("Should_WriteToDebug - hello, world!", this.traceListener.Messages);
55+
Assert.Contains("Should_WriteToTrace - hello, world!", this.traceListener.Messages);
5656
}
5757

5858
/// <summary>
59-
/// The debug target should use the configured layout to format its messages.
59+
/// The trace target should use the configured layout to format its messages.
6060
/// </summary>
6161
[Fact(DisplayName = "Should_UseLayout")]
6262
public void Should_UseLayout()
6363
{
6464
// Setup
6565
var layout = A.Fake<ILayout>();
6666
A.CallTo(() => layout.Format(A<LogEvent>.Ignored)).Returns("Should_UseLayout - formatted");
67-
var target = new DebugTarget();
67+
var target = new TraceTarget();
6868
target.SetLayout(layout);
6969

7070
// Execute
@@ -79,14 +79,14 @@ public void Should_UseLayout()
7979
}
8080

8181
/// <summary>
82-
/// The debug target should throw an invalid operation exception when no layout is given, and
82+
/// The trace target should throw an invalid operation exception when no layout is given, and
8383
/// the target is asked to write a log message.
8484
/// </summary>
8585
[Fact(DisplayName = "Should_UseLayout")]
8686
public void Should_ThrowInvalidOperationWithoutLayout()
8787
{
8888
// Setup
89-
var target = new DebugTarget();
89+
var target = new TraceTarget();
9090

9191
// Execute / Verify
9292
Assert.Throws(typeof(InvalidOperationException), () =>

Take2/NuLog/NuLog.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
<Compile Include="TagRouters\StandardTagRouter.cs" />
9595
<Compile Include="TagRouters\TagGroupProcessors\StandardTagGroupProcessor.cs" />
9696
<Compile Include="Targets\ConsoleTarget.cs" />
97-
<Compile Include="Targets\DebugTarget.cs" />
97+
<Compile Include="Targets\TraceTarget.cs" />
9898
<Compile Include="Targets\EventLogShim.cs" />
9999
<Compile Include="Targets\EventLogTarget.cs" />
100100
<Compile Include="Targets\IEventLog.cs" />
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
namespace NuLog.Targets
1010
{
1111
/// <summary>
12-
/// A logger target that writes to debug (System.Diagnostics).
12+
/// A logger target that writes to trace (System.Diagnostics).
1313
/// </summary>
14-
public class DebugTarget : LayoutTargetBase
14+
public class TraceTarget : LayoutTargetBase
1515
{
1616
public override void Write(LogEvent logEvent)
1717
{
@@ -20,7 +20,7 @@ public override void Write(LogEvent logEvent)
2020
{
2121
// Use the layout to format the log event, before writing it to debug.
2222
var formatted = this.Layout.Format(logEvent);
23-
Debug.Write(formatted);
23+
Trace.Write(formatted);
2424
}
2525
else
2626
{

0 commit comments

Comments
 (0)