forked from serilog/serilog
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved IOTextWriter to new sink project
- Loading branch information
Showing
8 changed files
with
101 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/Serilog.Sinks.IOTextWriter/IOTextWriterConfigurationExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using System.IO; | ||
using Serilog.Configuration; | ||
using Serilog.Core; | ||
using Serilog.Events; | ||
using Serilog.Formatting.Display; | ||
using Serilog.Sinks.IOTextWriter; | ||
|
||
namespace Serilog | ||
{ | ||
public static class IOTextWriterConfigurationExtensions | ||
{ | ||
/// <summary> | ||
/// Write log events to the provided <see cref="TextWriter"/>. | ||
/// </summary> | ||
/// <param name="sinkConfiguration">Logger sink configuration.</param> | ||
/// <param name="textWriter">The text writer to write log events to.</param> | ||
/// <param name="outputTemplate">Message template describing the output format.</param> | ||
/// <param name="restrictedToMinimumLevel">The minimum level for | ||
/// events passed through the sink. Ignored when <paramref name="levelSwitch"/> is specified.</param> | ||
/// <param name="levelSwitch">A switch allowing the pass-through minimum level | ||
/// to be changed at runtime.</param> | ||
/// <returns>Configuration object allowing method chaining.</returns> | ||
/// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param> | ||
/// <exception cref="ArgumentNullException"></exception> | ||
public static LoggerConfiguration TextWriter( | ||
this LoggerSinkConfiguration sinkConfiguration, | ||
TextWriter textWriter, | ||
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum, | ||
string outputTemplate = LoggerConfigurationFullNetFxExtensions.DefaultOutputTemplate, | ||
IFormatProvider formatProvider = null, | ||
LoggingLevelSwitch levelSwitch = null) | ||
{ | ||
if (textWriter == null) throw new ArgumentNullException(nameof(textWriter)); | ||
if (outputTemplate == null) throw new ArgumentNullException(nameof(outputTemplate)); | ||
|
||
var formatter = new MessageTemplateTextFormatter(outputTemplate, formatProvider); | ||
var sink = new TextWriterSink(textWriter, formatter); | ||
return sinkConfiguration.Sink(sink, restrictedToMinimumLevel, levelSwitch); | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/Serilog.Sinks.IOTextWriter/Serilog.Sinks.IOTextWriter.xproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion> | ||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> | ||
</PropertyGroup> | ||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" /> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectGuid>e85abec7-9b4c-432c-9a04-ac5be9205d9f</ProjectGuid> | ||
<RootNamespace>Serilog</RootNamespace> | ||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath> | ||
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
</PropertyGroup> | ||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" /> | ||
</Project> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"version": "2.0.0-beta-*", | ||
"description": "The IO Text Writer sink for Serilog - Simple .NET logging with fully-structured events", | ||
"authors": [ "Serilog Contributors" ], | ||
"tags": [ "serilog", "IO", "text", "writer"], | ||
"projectUrl": "http://serilog.net", | ||
"licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0", | ||
"iconUrl": "http://serilog.net/images/serilog-sink-nuget.png", | ||
"dependencies": { | ||
"Serilog": { "target": "project" } | ||
}, | ||
"compilationOptions": { | ||
"keyFile": "../../assets/Serilog.snk" | ||
}, | ||
"frameworks": { | ||
"net45": { | ||
}, | ||
"dotnet5.1": { | ||
"dependencies": { | ||
"System.IO": "4.0.11-beta-23516" | ||
} | ||
}, | ||
"dotnet5.4": { | ||
"dependencies": { | ||
"System.IO": "4.0.11-beta-23516" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters