Skip to content

Commit

Permalink
Moved Observable Sink to new project
Browse files Browse the repository at this point in the history
  • Loading branch information
merbla committed Jan 21, 2016
1 parent 82f99b3 commit 1c56af8
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 24 deletions.
7 changes: 7 additions & 0 deletions Serilog.sln
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Serilog.Sinks.SystemConsole
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Serilog.Sinks.PeriodicBatching", "src\Serilog.Sinks.PeriodicBatching\Serilog.Sinks.PeriodicBatching.xproj", "{324C2F52-D9F7-4844-9BC4-9906E228D380}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Serilog.Sinks.Observable", "src\Serilog.Sinks.Observable\Serilog.Sinks.Observable.xproj", "{8D6C0BB9-D04D-49B6-9043-4A776AD275D5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -73,6 +75,10 @@ Global
{324C2F52-D9F7-4844-9BC4-9906E228D380}.Debug|Any CPU.Build.0 = Debug|Any CPU
{324C2F52-D9F7-4844-9BC4-9906E228D380}.Release|Any CPU.ActiveCfg = Release|Any CPU
{324C2F52-D9F7-4844-9BC4-9906E228D380}.Release|Any CPU.Build.0 = Release|Any CPU
{8D6C0BB9-D04D-49B6-9043-4A776AD275D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8D6C0BB9-D04D-49B6-9043-4A776AD275D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8D6C0BB9-D04D-49B6-9043-4A776AD275D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8D6C0BB9-D04D-49B6-9043-4A776AD275D5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -87,5 +93,6 @@ Global
{A3E6E5B4-995F-4C3D-9673-A4B6000F4E21} = {9EC69873-5A97-4C25-AB5A-31DDE589B2D9}
{50B24ACA-D8F0-4268-A477-871B0A92A04A} = {9EC69873-5A97-4C25-AB5A-31DDE589B2D9}
{324C2F52-D9F7-4844-9BC4-9906E228D380} = {9EC69873-5A97-4C25-AB5A-31DDE589B2D9}
{8D6C0BB9-D04D-49B6-9043-4A776AD275D5} = {9EC69873-5A97-4C25-AB5A-31DDE589B2D9}
EndGlobalSection
EndGlobal
34 changes: 34 additions & 0 deletions src/Serilog.Sinks.Observable/ObservableConfigurationExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;
using Serilog.Configuration;
using Serilog.Core;
using Serilog.Events;
using Serilog.Sinks.Observable;

namespace Serilog
{
public static class ObservableConfigurationExtensions
{
/// <summary>
/// Write events to Rx observers.
/// </summary>
/// <param name="sinkConfiguration">Logger sink configuration.</param>
/// <param name="configureObservers">An action that provides an observable
/// to which observers can subscribe.</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>
public static LoggerConfiguration Observers(
this LoggerSinkConfiguration sinkConfiguration,
Action<IObservable<LogEvent>> configureObservers,
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
LoggingLevelSwitch levelSwitch = null)
{
if (configureObservers == null) throw new ArgumentNullException(nameof(configureObservers));
var observable = new ObservableSink();
configureObservers(observable);
return sinkConfiguration.Sink(observable, restrictedToMinimumLevel, levelSwitch);
}
}
}
11 changes: 11 additions & 0 deletions src/Serilog.Sinks.Observable/Properties/InternalsVisibleTo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Reflection;
using System.Runtime.CompilerServices;

[assembly: AssemblyVersion("2.0.0.0")]

[assembly: InternalsVisibleTo("Serilog.Tests, PublicKey=" +
"0024000004800000940000000602000000240000525341310004000001000100fb8d13fd344a1c" +
"6fe0fe83ef33c1080bf30690765bc6eb0df26ebfdf8f21670c64265b30db09f73a0dea5b3db4c9" +
"d18dbf6d5a25af5ce9016f281014d79dc3b4201ac646c451830fc7e61a2dfd633d34c39f87b818" +
"94191652df5ac63cc40c77f3542f702bda692e6e8a9158353df189007a49da0f3cfd55eb250066" +
"b19485ec")]
18 changes: 18 additions & 0 deletions src/Serilog.Sinks.Observable/Serilog.Sinks.Observable.xproj
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>8d6c0bb9-d04d-49b6-9043-4a776ad275d5</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>
34 changes: 34 additions & 0 deletions src/Serilog.Sinks.Observable/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"version": "2.0.0-beta-*",
"description": "The observable sink for Serilog - Simple .NET logging with fully-structured events",
"authors": [ "Serilog Contributors" ],
"tags": [ "serilog", "observable", "reactive" ],
"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": {
},
"netcore50": {
"dependencies": {
"System.Collections.Concurrent": "4.0.11-beta-23516"
}
},
"dotnet5.2": {
"dependencies": {
"System.Collections.Concurrent": "4.0.11-beta-23516"
}
},
"dotnet5.4": {
"dependencies": {
"System.Collections.Concurrent": "4.0.11-beta-23516"
}
}
}
}
24 changes: 1 addition & 23 deletions src/Serilog/Configuration/LoggerSinkConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
using Serilog.Events;
using Serilog.Formatting.Display;
using Serilog.Sinks.IOTextWriter;
using Serilog.Sinks.Observable;

namespace Serilog.Configuration
{
Expand Down Expand Up @@ -177,27 +176,6 @@ public LoggerConfiguration Logger(
{
if (logger == null) throw new ArgumentNullException(nameof(logger));
return Sink(new SecondaryLoggerSink(logger, attemptDispose: false), restrictedToMinimumLevel);
}

/// <summary>
/// Write events to Rx observers.
/// </summary>
/// <param name="configureObservers">An action that provides an observable
/// to which observers can subscribe.</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>
public LoggerConfiguration Observers(
Action<IObservable<LogEvent>> configureObservers,
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
LoggingLevelSwitch levelSwitch = null)
{
if (configureObservers == null) throw new ArgumentNullException(nameof(configureObservers));
var observable = new ObservableSink();
configureObservers(observable);
return Sink(observable, restrictedToMinimumLevel, levelSwitch);
}
}
}
}
3 changes: 2 additions & 1 deletion test/Serilog.Tests/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"Serilog.Sinks.DiagnosticTrace": { "target": "project" },
"Serilog.Sinks.IOFile": { "target": "project" },
"Serilog.Sinks.RollingFile": { "target": "project" },
"Serilog.Sinks.PeriodicBatching": {"target": "project"}
"Serilog.Sinks.PeriodicBatching": { "target": "project" },
"Serilog.Sinks.Observable": {"target": "project"}
},
"frameworks": {
"dnx451": {
Expand Down

0 comments on commit 1c56af8

Please sign in to comment.