Skip to content

Commit

Permalink
Merge pull request #91 from serilog/dev
Browse files Browse the repository at this point in the history
2.0.0 Release
  • Loading branch information
nblumhardt authored Aug 18, 2017
2 parents d9e9994 + 7bda6f2 commit 8ed7d97
Show file tree
Hide file tree
Showing 23 changed files with 227 additions and 280 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
Expand Down Expand Up @@ -196,3 +196,6 @@ FakesAssemblies/
*.opt
*.orig
project.lock.json

# JetBrains Rider
.idea
7 changes: 6 additions & 1 deletion Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ foreach ($src in ls src/*) {

echo "build: Packaging project in $src"

& dotnet pack -c Release -o ..\..\artifacts --version-suffix=$suffix
if($suffix) {
& dotnet pack -c Release --include-source -o ..\..\artifacts --version-suffix=$suffix
} else {
& dotnet pack -c Release --include-source -o ..\..\artifacts
}

if($LASTEXITCODE -ne 0) { exit 1 }

Pop-Location
Expand Down
12 changes: 6 additions & 6 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
version: '{build}'
skip_tags: true
image: Visual Studio 2015
image: Visual Studio 2017 Preview
configuration: Release
install:
- ps: mkdir -Force ".\build\" | Out-Null
- ps: Invoke-WebRequest "https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0-preview2/scripts/obtain/dotnet-install.ps1" -OutFile ".\build\installcli.ps1"
- ps: $env:DOTNET_INSTALL_DIR = "$pwd\.dotnetcli"
- ps: '& .\build\installcli.ps1 -InstallDir "$env:DOTNET_INSTALL_DIR" -NoPath -Version 1.0.0-preview2-003121'
- ps: $env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path"
#- ps: Invoke-WebRequest "https://raw.githubusercontent.com/dotnet/cli/release/2.0.0/scripts/obtain/dotnet-install.ps1" -OutFile ".\build\installcli.ps1"
#- ps: $env:DOTNET_INSTALL_DIR = "$pwd\.dotnetcli"
#- ps: '& .\build\installcli.ps1 -InstallDir "$env:DOTNET_INSTALL_DIR" -NoPath -Version 2.0.0-preview2-006497'
#- ps: $env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path"
build_script:
- ps: ./Build.ps1
test: off
Expand All @@ -27,4 +27,4 @@ deploy:
tag: v$(appveyor_build_version)
on:
branch: master

3 changes: 1 addition & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-preview2-003121"
"version": "2.0.0-preview2-006497"
}
}
17 changes: 11 additions & 6 deletions samples/Sample/Program.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Serilog;

namespace Sample
{
public static class Program
public class Program
{
public static void Main(string[] args)
{
Expand All @@ -13,18 +14,22 @@ public static void Main(string[] args)
.WriteTo.LiterateConsole()
.CreateLogger();

var logger = new LoggerFactory()
.AddSerilog()
.CreateLogger(typeof(Program).FullName);
var services = new ServiceCollection()
.AddLogging(builder =>
{
builder.AddSerilog();
});

logger.LogInformation("Starting");
var serviceProvider = services.BuildServiceProvider();
// getting the logger using the class's name is conventional
var logger = serviceProvider.GetRequiredService<ILogger<Program>>();

var startTime = DateTimeOffset.UtcNow;
logger.LogInformation(1, "Started at {StartTime} and 0x{Hello:X} is hex of 42", startTime, 42);

try
{
throw new Exception("Boom");
throw new Exception("Boom!");
}
catch (Exception ex)
{
Expand Down
20 changes: 20 additions & 0 deletions samples/Sample/Sample.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net461;netcoreapp2.0</TargetFrameworks>
<AssemblyName>Sample</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>Sample</PackageId>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Serilog.Extensions.Logging\Serilog.Extensions.Logging.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.0.0" />
<PackageReference Include="Serilog.Sinks.Literate" Version="2.0.0" />
</ItemGroup>

</Project>
15 changes: 0 additions & 15 deletions samples/Sample/Sample.xproj

This file was deleted.

27 changes: 0 additions & 27 deletions samples/Sample/project.json

This file was deleted.

9 changes: 6 additions & 3 deletions samples/WebSample/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,19 @@ public Startup(IHostingEnvironment env)
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddLogging(builder =>
{
// Specifying dispose: true closes and flushes the Serilog `Log` class when the app shuts down.
builder.AddSerilog(dispose: true);
});

// Add framework services.
services.AddMvc();
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
// Specifying dispose: true closes and flushes the Serilog `Log` class when the app shuts down.
loggerFactory.AddSerilog(dispose: true);

if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
Expand Down
41 changes: 41 additions & 0 deletions samples/WebSample/WebSample.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyName>WebSample</AssemblyName>
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<None Update="wwwroot\**\*;Views\**\*;Areas\**\Views">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Serilog.Extensions.Logging\Serilog.Extensions.Logging.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.0.3" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="1.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.0.2" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.0.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.0.2" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.0.2" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.0.1" />
<PackageReference Include="Serilog.Settings.Configuration" Version="2.3.1" />
<PackageReference Include="Serilog.Sinks.Trace" Version="2.1.0" />
<PackageReference Include="Serilog.Sinks.Literate" Version="2.1.0" />
<PackageReference Include="Serilog.Sinks.Seq" Version="3.2.0" />
</ItemGroup>
<Target Name="PrepublishScript" BeforeTargets="PrepareForPublish">
<Exec Command="bower install" />
<Exec Command="dotnet bundle" />
</Target>
<ItemGroup>
<DotNetCliToolReference Include="BundlerMinifier.Core" Version="2.2.301" />
</ItemGroup>
</Project>
23 changes: 0 additions & 23 deletions samples/WebSample/WebSample.xproj

This file was deleted.

70 changes: 0 additions & 70 deletions samples/WebSample/project.json

This file was deleted.

14 changes: 7 additions & 7 deletions serilog-extensions-logging.sln
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
# Visual Studio 15
VisualStudioVersion = 15.0.26114.2
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{A1893BD1-333D-4DFE-A0F0-DDBB2FE526E0}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Serilog.Extensions.Logging", "src\Serilog.Extensions.Logging\Serilog.Extensions.Logging.xproj", "{903CD13A-D54B-4CEC-A55F-E22AE3D93B3B}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Extensions.Logging", "src\Serilog.Extensions.Logging\Serilog.Extensions.Logging.csproj", "{903CD13A-D54B-4CEC-A55F-E22AE3D93B3B}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Serilog.Extensions.Logging.Tests", "test\Serilog.Extensions.Logging.Tests\Serilog.Extensions.Logging.Tests.xproj", "{37EADF84-5E41-4224-A194-1E3299DCD0B8}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Extensions.Logging.Tests", "test\Serilog.Extensions.Logging.Tests\Serilog.Extensions.Logging.Tests.csproj", "{37EADF84-5E41-4224-A194-1E3299DCD0B8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{E30F638E-BBBE-4AD1-93CE-48CC69CFEFE1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{F2407211-6043-439C-8E06-3641634332E7}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Sample", "samples\Sample\Sample.xproj", "{65357FBC-9BC4-466D-B621-1C3A19BC2A78}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample", "samples\Sample\Sample.csproj", "{65357FBC-9BC4-466D-B621-1C3A19BC2A78}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "assets", "assets", "{9C21B9DF-AEDD-4AA6-BEA4-912DEF3E5B8E}"
ProjectSection(SolutionItems) = preProject
appveyor.yml = appveyor.yml
Build.ps1 = Build.ps1
global.json = global.json
README.md = README.md
assets\Serilog.snk = assets\Serilog.snk
global.json = global.json
EndProjectSection
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "WebSample", "samples\WebSample\WebSample.xproj", "{486DF7EB-128D-4C79-8B97-9CEFEADDB948}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebSample", "samples\WebSample\WebSample.csproj", "{486DF7EB-128D-4C79-8B97-9CEFEADDB948}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
14 changes: 11 additions & 3 deletions src/Serilog.Extensions.Logging/Extensions/Logging/SerilogLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,20 @@ public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Except

if (messageTemplate == null)
{
var propertyName = state != null ? "State" :
(formatter != null ? "Message" : null);
string propertyName = null;
if (state != null)
{
propertyName = "State";
messageTemplate = "{State:l}";
}
else if (formatter != null)
{
propertyName = "Message";
messageTemplate = "{Message:l}";
}

if (propertyName != null)
{
messageTemplate = $"{{{propertyName}:l}}";
LogEventProperty property;
if (logger.BindProperty(propertyName, AsLoggableValue(state, formatter), false, out property))
properties.Add(property);
Expand Down
Loading

0 comments on commit 8ed7d97

Please sign in to comment.