Skip to content

Commit 4efaefb

Browse files
authored
Merge pull request #4 from HakanL/patch-1
Added trim to remove empty newline in output
2 parents 74a8a54 + f78e1bd commit 4efaefb

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/Serilog.Sinks.Debug/Serilog.Sinks.Debug.csproj

+13-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<Description>A Serilog sink that writes log events to the debug output window.</Description>
55
<VersionPrefix>1.0.1</VersionPrefix>
66
<Authors>Serilog Contributors</Authors>
7-
<TargetFrameworks>netstandard1.0</TargetFrameworks>
7+
<TargetFrameworks>net45;net46;netstandard1.0;netstandard2.0</TargetFrameworks>
88
<AssemblyName>Serilog.Sinks.Debug</AssemblyName>
99
<AssemblyOriginatorKeyFile>../../assets/Serilog.snk</AssemblyOriginatorKeyFile>
1010
<SignAssembly>true</SignAssembly>
@@ -34,4 +34,16 @@
3434
<PackageReference Include="System.Diagnostics.Debug" Version="4.3.0" />
3535
</ItemGroup>
3636

37+
<PropertyGroup Condition=" '$(TargetFramework)' == 'net45' ">
38+
<DefineConstants>$(DefineConstants);DEBUG_WRITE</DefineConstants>
39+
</PropertyGroup>
40+
41+
<PropertyGroup Condition=" '$(TargetFramework)' == 'net46' ">
42+
<DefineConstants>$(DefineConstants);DEBUG_WRITE</DefineConstants>
43+
</PropertyGroup>
44+
45+
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
46+
<DefineConstants>$(DefineConstants);DEBUG_WRITE</DefineConstants>
47+
</PropertyGroup>
48+
3749
</Project>

src/Serilog.Sinks.Debug/Sinks/Debug/DebugSink.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ public void Emit(LogEvent logEvent)
3434
using (var buffer = new StringWriter())
3535
{
3636
_formatter.Format(logEvent, buffer);
37-
System.Diagnostics.Debug.WriteLine(buffer.ToString());
37+
#if DEBUG_WRITE
38+
System.Diagnostics.Debug.Write(buffer.ToString());
39+
#else
40+
System.Diagnostics.Debug.WriteLine(buffer.ToString().Trim());
41+
#endif
3842
}
3943
}
4044
}

0 commit comments

Comments
 (0)