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.
Initial cut of console sink as an example of porting sinks
- Loading branch information
Showing
7 changed files
with
134 additions
and
28 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System; | ||
using Serilog.Configuration; | ||
using Serilog.Core; | ||
using Serilog.Events; | ||
using Serilog.Formatting.Display; | ||
|
||
|
||
namespace Serilog.Sinks.SystemConsole | ||
{ | ||
public static class LoggingExtentsions | ||
{ | ||
const string DefaultConsoleOutputTemplate = "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level}] {Message}{NewLine}{Exception}"; | ||
|
||
/// <summary> | ||
/// Writes log events to <see cref="System.Console"/>. | ||
/// </summary> | ||
/// <param name="sinkConfiguration">Logger sink configuration.</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> | ||
/// <param name="outputTemplate">A message template describing the format used to write to the sink. | ||
/// the default is "{Timestamp} [{Level}] {Message}{NewLine}{Exception}".</param> | ||
/// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param> | ||
/// <returns>Configuration object allowing method chaining.</returns> | ||
public static LoggerConfiguration Console( | ||
this LoggerSinkConfiguration sinkConfiguration, | ||
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum, | ||
string outputTemplate = DefaultConsoleOutputTemplate, | ||
IFormatProvider formatProvider = null, | ||
LoggingLevelSwitch levelSwitch = null) | ||
{ | ||
if (sinkConfiguration == null) throw new ArgumentNullException(nameof(sinkConfiguration)); | ||
if (outputTemplate == null) throw new ArgumentNullException(nameof(outputTemplate)); | ||
var formatter = new MessageTemplateTextFormatter(outputTemplate, formatProvider); | ||
return sinkConfiguration.Sink(new ConsoleSink(formatter), restrictedToMinimumLevel, levelSwitch); | ||
} | ||
} | ||
} |
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,20 @@ | ||
<?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>866a028e-27db-49a0-ac78-e5fef247c099</ProjectGuid> | ||
<RootNamespace>Serilog.Sinks.Console</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> |
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,60 @@ | ||
{ | ||
"version": "2.0.0-beta-*", | ||
"description": "The console sink for Seriolog - Simple .NET logging with fully-structured events", | ||
"authors": [ "Serilog Contributors" ], | ||
"tags": [ "serilog", "logging", "semantic", "structured", "console" ], | ||
"projectUrl": "http://serilog.net", | ||
"licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0", | ||
"iconUrl": "http://serilog.net/images/serilog-nuget.png", | ||
"frameworks": { | ||
"net40": { | ||
"compilationOptions": { | ||
"keyFile": "../../assets/Serilog.snk" | ||
}, | ||
"frameworkAssemblies": { | ||
"System.Configuration": "" | ||
}, | ||
"dependencies": { | ||
"Microsoft.Bcl.Async": "1.0.168", | ||
"Serilog": "2.0.0-beta-*" | ||
} | ||
}, | ||
"net45": { | ||
"compilationOptions": { | ||
"keyFile": "../../assets/Serilog.snk" | ||
}, | ||
"frameworkAssemblies": { | ||
"System.Configuration": "" | ||
}, | ||
"dependencies": { | ||
"Serilog": "2.0.0-beta-*" | ||
} | ||
}, | ||
"dnx451": { | ||
"compilationOptions": { | ||
"keyFile": "../../assets/Serilog.snk" | ||
}, | ||
"frameworkAssemblies": { | ||
"System.Configuration": "" | ||
}, | ||
"dependencies": { | ||
"Serilog": "2.0.0-beta-*" | ||
} | ||
}, | ||
"dotnet5.4": { | ||
"dependencies": { | ||
"Microsoft.CSharp": "4.0.1-beta-23516", | ||
"Serilog": "2.0.0-beta-*", | ||
"System.Collections.Concurrent": "4.0.11-beta-23516", | ||
"System.Console": "4.0.0-beta-23516", | ||
"System.Diagnostics.Process": "4.1.0-beta-23516", | ||
"System.Diagnostics.TraceSource": "4.0.0-beta-23516", | ||
"System.IO": "4.0.11-beta-23516", | ||
"System.IO.FileSystem": "4.0.1-beta-23516", | ||
"System.Linq": "4.0.1-beta-23516", | ||
"System.Text.RegularExpressions": "4.0.11-beta-23516", | ||
"System.Threading.Thread": "4.0.0-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