diff --git a/.gitignore b/.gitignore
index f9ae2f4e1..ce725c264 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,71 +1,220 @@
-#OS junk files
-[Tt]humbs.db
-*.DS_Store
+# Created by https://www.gitignore.io/api/visualstudio
-#Visual Studio files
-*.[Oo]bj
+### VisualStudio ###
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+
+# User-specific files
+*.suo
*.user
-*.aps
-*.pch
-*.vspscc
-*.vssscc
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+build/
+bld/
+[Bb]in/
+[Oo]bj/
+
+# Visual Studio 2015 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUNIT
+*.VisualState.xml
+TestResult.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# DNX
+project.lock.json
+artifacts/
+
*_i.c
*_p.c
-*.ncb
-*.suo
+*_i.h
+*.ilk
+*.meta
+*.obj
+*.pch
+*.pdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
*.tlb
+*.tli
*.tlh
-*.bak
-*.[Cc]ache
-*.ilk
+*.tmp
+*.tmp_proj
*.log
-*.lib
-*.sbr
-*.sdf
-*.opensdf
-*.unsuccessfulbuild
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
ipch/
-obj/
-[Bb]in
-bin40/
-Ankh.NoLoad
-*.vspx
+*.aps
+*.ncb
+*.opensdf
+*.sdf
+*.cachefile
+
+# Visual Studio profiler
*.psess
+*.vsp
+*.vspx
-#MonoDevelop
-*.pidb
-*.userprefs
+# TFS 2012 Local Workspace
+$tf/
-#Tooling
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
_ReSharper*/
-*.resharper
-[Tt]est[Rr]esult*
-*.sass-cache
-*.orig
-*.GhostDoc.xml
+*.[Rr]e[Ss]harper
+*.DotSettings.user
-#Project files
-[Bb]uild/
-*.ide
+# JustCode is a .NET coding add-in
+.JustCode
-#Subversion files
-.svn
+# TeamCity is a build add-in
+_TeamCity*
-# Office Temp Files
-~$*
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
-#NuGet
-packages/*
-src/serilog/packages/*
-!packages/repositories.config
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# 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
+
+# NuGet Packages
*.nupkg
+# The packages folder can be ignored because of Package Restore
+**/packages/*
+# except build/, which is used as an MSBuild target.
+!**/packages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/packages/repositories.config
+
+# Windows Azure Build Output
+csx/
+*.build.csdef
+
+# Windows Store app package directory
+AppPackages/
-#ncrunch
-*ncrunch*
-*crunch*.local.xml
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!*.[Cc]ache/
-# visual studio database projects
+# Others
+ClientBin/
+[Ss]tyle[Cc]op.*
+~$*
+*~
*.dbmdl
+*.dbproj.schemaview
+*.pfx
+*.publishsettings
+node_modules/
+orleans.codegen.cs
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
-#Test files
-*.testsettings
+# SQL Server files
+*.mdf
+*.ldf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+*.orig
diff --git a/Build.ps1 b/Build.ps1
index bde75f2da..ae539c910 100644
--- a/Build.ps1
+++ b/Build.ps1
@@ -1,87 +1,103 @@
-param(
- [String] $majorMinor = "0.0", # 1.4
- [String] $patch = "0", # $env:APPVEYOR_BUILD_VERSION
- [String] $branch = "private", # $env:APPVEYOR_REPO_BRANCH
- [String] $customLogger = "", # C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll
- [Switch] $notouch
-)
-
-function Set-AssemblyVersions($informational, $file, $assembly)
+function Install-Dnvm
{
- (Get-Content assets/CommonAssemblyInfo.cs) |
- ForEach-Object { $_ -replace """1.0.0.0""", """$assembly""" } |
- ForEach-Object { $_ -replace """1.0.0""", """$informational""" } |
- ForEach-Object { $_ -replace """1.1.1.1""", """$file""" } |
- Set-Content assets/CommonAssemblyInfo.cs
+ & where.exe dnvm 2>&1 | Out-Null
+ if(($LASTEXITCODE -ne 0) -Or ((Test-Path Env:\APPVEYOR) -eq $true))
+ {
+ Write-Host "DNVM not found"
+ &{$Branch='dev';iex ((New-Object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))}
+
+ # Normally this happens automatically during install but AppVeyor has
+ # an issue where you may need to manually re-run setup from within this process.
+ if($env:DNX_HOME -eq $NULL)
+ {
+ Write-Host "Initial DNVM environment setup failed; running manual setup"
+ $tempDnvmPath = Join-Path $env:TEMP "dnvminstall"
+ $dnvmSetupCmdPath = Join-Path $tempDnvmPath "dnvm.ps1"
+ & $dnvmSetupCmdPath setup
+ }
+ }
}
-function Install-NuGetPackages()
+function Get-DnxVersion
{
- nuget restore Serilog.sln
+ $globalJson = Join-Path $PSScriptRoot "global.json"
+ $jsonData = Get-Content -Path $globalJson -Raw | ConvertFrom-JSON
+ return $jsonData.sdk.version
}
-function Invoke-MSBuild($solution, $customLogger)
+function Restore-Packages
{
- if ($customLogger)
- {
- msbuild "$solution" /verbosity:minimal /p:Configuration=Release /logger:"$customLogger"
- }
- else
- {
- msbuild "$solution" /verbosity:minimal /p:Configuration=Release
- }
+ param([string] $DirectoryName)
+ & dnu restore ("""" + $DirectoryName + """")
}
-function Invoke-NuGetPackProj($csproj)
+function Build-Projects
{
- nuget pack -Prop Configuration=Release -Symbols $csproj
+ param([string] $DirectoryName)
+ & dnu build ("""" + $DirectoryName + """") --configuration Release --out .\artifacts\testbin; if($LASTEXITCODE -ne 0) { exit 1 }
+ & dnu pack ("""" + $DirectoryName + """") --configuration Release --out .\artifacts\packages; if($LASTEXITCODE -ne 0) { exit 1 }
}
-function Invoke-NuGetPackSpec($nuspec, $version)
+function Build-TestProjects
{
- nuget pack $nuspec -Version $version -OutputDirectory ..\..\
+ param([string] $DirectoryName)
+ & dnu build ("""" + $DirectoryName + """") --configuration Release --out .\artifacts\testbin; if($LASTEXITCODE -ne 0) { exit 1 }
}
-function Invoke-NuGetPack($version)
+function Test-Projects
{
- ls src/**/*.csproj |
- Where-Object { -not ($_.Name -like "*net40*") } |
- Where-Object { -not ($_.Name -like "*FullNetFx*") } |
- Where-Object { -not ($_.Name -eq "Serilog.csproj") } |
- ForEach-Object { Invoke-NuGetPackProj $_ }
-
- pushd .\src\Serilog
- Invoke-NuGetPackSpec "Serilog.nuspec" $version
- popd
+ param([string] $DirectoryName)
+ & dnx -p ("""" + $DirectoryName + """") test; if($LASTEXITCODE -ne 0) { exit 2 }
}
-function Invoke-Build($majorMinor, $patch, $branch, $customLogger, $notouch)
+function Remove-PathVariable
{
- $target = (Get-Content ./CHANGES.md -First 1).Trim()
- $file = "$target.$patch"
- $package = $target
- if ($branch -ne "master")
- {
- $package = "$target-pre-$patch"
- }
+ param([string] $VariableToRemove)
+ $path = [Environment]::GetEnvironmentVariable("PATH", "User")
+ $newItems = $path.Split(';') | Where-Object { $_.ToString() -inotlike $VariableToRemove }
+ [Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "User")
+ $path = [Environment]::GetEnvironmentVariable("PATH", "Process")
+ $newItems = $path.Split(';') | Where-Object { $_.ToString() -inotlike $VariableToRemove }
+ [Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "Process")
+}
- Write-Output "Building Serilog $package"
+Push-Location $PSScriptRoot
- if (-not $notouch)
- {
- $assembly = "$majorMinor.0.0"
+$dnxVersion = Get-DnxVersion
- Write-Output "Assembly version will be set to $assembly"
- Set-AssemblyVersions $package $file $assembly
- }
+# Clean
+if(Test-Path .\artifacts) { Remove-Item .\artifacts -Force -Recurse }
- Install-NuGetPackages
-
- Invoke-MSBuild "Serilog-net40.sln" $customLogger
- Invoke-MSBuild "Serilog.sln" $customLogger
+# Remove the installed DNVM from the path and force use of
+# per-user DNVM (which we can upgrade as needed without admin permissions)
+Remove-PathVariable "*Program Files\Microsoft DNX\DNVM*"
- Invoke-NuGetPack $package
-}
+# Make sure per-user DNVM is installed
+Install-Dnvm
+
+# Install DNX
+dnvm install $dnxVersion -r CoreCLR -NoNative
+dnvm install $dnxVersion -r CLR -NoNative
+dnvm use $dnxVersion -r CLR
+
+# Package restore
+Get-ChildItem -Path . -Filter *.xproj -Recurse | ForEach-Object { Restore-Packages $_.DirectoryName }
+
+# Set build number
+$env:DNX_BUILD_VERSION = @{ $true = $env:APPVEYOR_BUILD_NUMBER; $false = 1 }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
+Write-Host "Build number: " $env:DNX_BUILD_VERSION
+
+# Build/package
+Get-ChildItem -Path .\src -Filter *.xproj -Recurse | ForEach-Object { Build-Projects $_.DirectoryName }
+Get-ChildItem -Path .\test -Filter *.xproj -Recurse | ForEach-Object { Build-TestProjects $_.DirectoryName }
+
+# Test
+Get-ChildItem -Path .\test -Filter *.xproj -Recurse | ForEach-Object { Test-Projects $_.DirectoryName }
+
+# Switch to Core CLR
+dnvm use $dnxVersion -r CoreCLR
+
+# Test again
+Get-ChildItem -Path .\test -Filter *.xproj -Recurse | ForEach-Object { Test-Projects $_.DirectoryName }
-$ErrorActionPreference = "Stop"
-Invoke-Build $majorMinor $patch $branch $customLogger $notouch
+Pop-Location
diff --git a/NuGet.Config b/NuGet.Config
new file mode 100644
index 000000000..26aec7095
--- /dev/null
+++ b/NuGet.Config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/Serilog-net40.sln b/Serilog-net40.sln
deleted file mode 100644
index 3f67c8365..000000000
--- a/Serilog-net40.sln
+++ /dev/null
@@ -1,34 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2013
-VisualStudioVersion = 12.0.31101.0
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog-net40", "src\Serilog\Serilog-net40.csproj", "{0915DBD9-0F7C-4439-8D9E-74C3D579B219}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.FullNetFx-net40", "src\Serilog.FullNetFx\Serilog.FullNetFx-net40.csproj", "{7A9E1095-167D-402A-B43D-B36B97FF183D}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Tests-net40", "test\Serilog.Tests\Serilog.Tests-net40.csproj", "{D5648551-D19D-41E3-9FC1-E74B111EEF41}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {0915DBD9-0F7C-4439-8D9E-74C3D579B219}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {0915DBD9-0F7C-4439-8D9E-74C3D579B219}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {0915DBD9-0F7C-4439-8D9E-74C3D579B219}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {0915DBD9-0F7C-4439-8D9E-74C3D579B219}.Release|Any CPU.Build.0 = Release|Any CPU
- {7A9E1095-167D-402A-B43D-B36B97FF183D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {7A9E1095-167D-402A-B43D-B36B97FF183D}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {7A9E1095-167D-402A-B43D-B36B97FF183D}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {7A9E1095-167D-402A-B43D-B36B97FF183D}.Release|Any CPU.Build.0 = Release|Any CPU
- {D5648551-D19D-41E3-9FC1-E74B111EEF41}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {D5648551-D19D-41E3-9FC1-E74B111EEF41}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {D5648551-D19D-41E3-9FC1-E74B111EEF41}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {D5648551-D19D-41E3-9FC1-E74B111EEF41}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/Serilog.sln b/Serilog.sln
index 5da528f9e..f725e1bfd 100644
--- a/Serilog.sln
+++ b/Serilog.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2013
-VisualStudioVersion = 12.0.31101.0
+# Visual Studio 14
+VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{037440DE-440B-4129-9F7A-09B42D00397E}"
EndProject
@@ -12,21 +12,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "assets", "assets", "{E9D1B5
.editorconfig = .editorconfig
Build.ps1 = Build.ps1
assets\CommonAssemblyInfo.cs = assets\CommonAssemblyInfo.cs
+ global.json = global.json
+ NuGet.Config = NuGet.Config
README.md = README.md
assets\Serilog.snk = assets\Serilog.snk
EndProjectSection
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog", "src\Serilog\Serilog.csproj", "{0915DBD9-0F7C-4439-8D9E-74C3D579B219}"
+Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Serilog", "src\Serilog\Serilog.xproj", "{803CD13A-D54B-4CEC-A55F-E22AE3D93B3C}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Tests", "test\Serilog.Tests\Serilog.Tests.csproj", "{D5648551-D19D-41E3-9FC1-E74B111EEF41}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.FullNetFx", "src\Serilog.FullNetFx\Serilog.FullNetFx.csproj", "{7A9E1095-167D-402A-B43D-B36B97FF183D}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.PerformanceTests", "test\Serilog.PerformanceTests\Serilog.PerformanceTests.csproj", "{6A6504BF-CD5B-4C9E-88EB-5BD71CE3106A}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.SmokeTest", "test\Serilog.SmokeTest\Serilog.SmokeTest.csproj", "{58563C46-B781-4799-ABD5-9745F94478FD}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.MsTests", "test\Serilog.MsTests\Serilog.MsTests.csproj", "{7FC9FC46-5014-4461-A448-815E6CCE21E5}"
+Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Serilog.Tests", "test\Serilog.Tests\Serilog.Tests.xproj", "{3C2D8E01-5580-426A-BDD9-EC59CD98E618}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -34,40 +28,20 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {0915DBD9-0F7C-4439-8D9E-74C3D579B219}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {0915DBD9-0F7C-4439-8D9E-74C3D579B219}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {0915DBD9-0F7C-4439-8D9E-74C3D579B219}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {0915DBD9-0F7C-4439-8D9E-74C3D579B219}.Release|Any CPU.Build.0 = Release|Any CPU
- {D5648551-D19D-41E3-9FC1-E74B111EEF41}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {D5648551-D19D-41E3-9FC1-E74B111EEF41}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {D5648551-D19D-41E3-9FC1-E74B111EEF41}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {D5648551-D19D-41E3-9FC1-E74B111EEF41}.Release|Any CPU.Build.0 = Release|Any CPU
- {7A9E1095-167D-402A-B43D-B36B97FF183D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {7A9E1095-167D-402A-B43D-B36B97FF183D}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {7A9E1095-167D-402A-B43D-B36B97FF183D}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {7A9E1095-167D-402A-B43D-B36B97FF183D}.Release|Any CPU.Build.0 = Release|Any CPU
- {6A6504BF-CD5B-4C9E-88EB-5BD71CE3106A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {6A6504BF-CD5B-4C9E-88EB-5BD71CE3106A}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {6A6504BF-CD5B-4C9E-88EB-5BD71CE3106A}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {6A6504BF-CD5B-4C9E-88EB-5BD71CE3106A}.Release|Any CPU.Build.0 = Release|Any CPU
- {58563C46-B781-4799-ABD5-9745F94478FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {58563C46-B781-4799-ABD5-9745F94478FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {58563C46-B781-4799-ABD5-9745F94478FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {58563C46-B781-4799-ABD5-9745F94478FD}.Release|Any CPU.Build.0 = Release|Any CPU
- {7FC9FC46-5014-4461-A448-815E6CCE21E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {7FC9FC46-5014-4461-A448-815E6CCE21E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {7FC9FC46-5014-4461-A448-815E6CCE21E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {7FC9FC46-5014-4461-A448-815E6CCE21E5}.Release|Any CPU.Build.0 = Release|Any CPU
+ {803CD13A-D54B-4CEC-A55F-E22AE3D93B3C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {803CD13A-D54B-4CEC-A55F-E22AE3D93B3C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {803CD13A-D54B-4CEC-A55F-E22AE3D93B3C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {803CD13A-D54B-4CEC-A55F-E22AE3D93B3C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {3C2D8E01-5580-426A-BDD9-EC59CD98E618}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {3C2D8E01-5580-426A-BDD9-EC59CD98E618}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {3C2D8E01-5580-426A-BDD9-EC59CD98E618}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {3C2D8E01-5580-426A-BDD9-EC59CD98E618}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
- {0915DBD9-0F7C-4439-8D9E-74C3D579B219} = {037440DE-440B-4129-9F7A-09B42D00397E}
- {D5648551-D19D-41E3-9FC1-E74B111EEF41} = {0D135C0C-A60B-454A-A2F4-CD74A30E04B0}
- {7A9E1095-167D-402A-B43D-B36B97FF183D} = {037440DE-440B-4129-9F7A-09B42D00397E}
- {6A6504BF-CD5B-4C9E-88EB-5BD71CE3106A} = {0D135C0C-A60B-454A-A2F4-CD74A30E04B0}
- {58563C46-B781-4799-ABD5-9745F94478FD} = {0D135C0C-A60B-454A-A2F4-CD74A30E04B0}
- {7FC9FC46-5014-4461-A448-815E6CCE21E5} = {0D135C0C-A60B-454A-A2F4-CD74A30E04B0}
+ {803CD13A-D54B-4CEC-A55F-E22AE3D93B3C} = {037440DE-440B-4129-9F7A-09B42D00397E}
+ {3C2D8E01-5580-426A-BDD9-EC59CD98E618} = {0D135C0C-A60B-454A-A2F4-CD74A30E04B0}
EndGlobalSection
EndGlobal
diff --git a/Serilog.sln.DotSettings b/Serilog.sln.DotSettings
index b861b831b..e2434be72 100644
--- a/Serilog.sln.DotSettings
+++ b/Serilog.sln.DotSettings
@@ -29,6 +29,7 @@
DO_NOT_SHOW
DO_NOT_SHOW
DO_NOT_SHOW
+ HINT
ERROR
WARNING
ERROR
@@ -41,6 +42,7 @@
ERROR
ERROR
WARNING
+ HINT
ERROR
ERROR
ERROR
@@ -123,7 +125,8 @@
CHOP_ALWAYS
True
True
- <Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns">
+ <?xml version="1.0" encoding="utf-16"?>
+<Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns">
<TypePattern DisplayName="COM interfaces or structs">
<TypePattern.Match>
<Or>
@@ -134,77 +137,67 @@
<HasAttribute Name="System.Runtime.InteropServices.ComImport" />
</Or>
</And>
- <HasAttribute Name="System.Runtime.InteropServices.StructLayoutAttribute" />
+ <Kind Is="Struct" />
</Or>
</TypePattern.Match>
</TypePattern>
-
<TypePattern DisplayName="NUnit Test Fixtures" RemoveRegions="All">
<TypePattern.Match>
<And>
<Kind Is="Class" />
- <HasAttribute Name="NUnit.Framework.TestFixtureAttribute" Inherited="true" />
- <HasAttribute Name="NUnit.Framework.TestCaseFixtureAttribute" Inherited="true" />
+ <HasAttribute Name="NUnit.Framework.TestFixtureAttribute" Inherited="True" />
+ <HasAttribute Name="NUnit.Framework.TestCaseFixtureAttribute" Inherited="True" />
</And>
</TypePattern.Match>
-
<Entry DisplayName="Setup/Teardown Methods">
<Entry.Match>
<And>
<Kind Is="Method" />
<Or>
- <HasAttribute Name="NUnit.Framework.SetUpAttribute" Inherited="true" />
- <HasAttribute Name="NUnit.Framework.TearDownAttribute" Inherited="true" />
- <HasAttribute Name="NUnit.Framework.FixtureSetUpAttribute" Inherited="true" />
- <HasAttribute Name="NUnit.Framework.FixtureTearDownAttribute" Inherited="true" />
+ <HasAttribute Name="NUnit.Framework.SetUpAttribute" Inherited="True" />
+ <HasAttribute Name="NUnit.Framework.TearDownAttribute" Inherited="True" />
+ <HasAttribute Name="NUnit.Framework.FixtureSetUpAttribute" Inherited="True" />
+ <HasAttribute Name="NUnit.Framework.FixtureTearDownAttribute" Inherited="True" />
</Or>
</And>
</Entry.Match>
</Entry>
-
<Entry DisplayName="All other members" />
-
- <Entry DisplayName="Test Methods" Priority="100">
+ <Entry Priority="100" DisplayName="Test Methods">
<Entry.Match>
<And>
<Kind Is="Method" />
- <HasAttribute Name="NUnit.Framework.TestAttribute" Inherited="false" />
+ <HasAttribute Name="NUnit.Framework.TestAttribute" />
</And>
</Entry.Match>
-
<Entry.SortBy>
<Name />
</Entry.SortBy>
</Entry>
</TypePattern>
-
<TypePattern DisplayName="Default Pattern">
- <Entry DisplayName="Public Delegates" Priority="100">
+ <Entry Priority="100" DisplayName="Public Delegates">
<Entry.Match>
<And>
<Access Is="Public" />
<Kind Is="Delegate" />
</And>
</Entry.Match>
-
<Entry.SortBy>
<Name />
</Entry.SortBy>
</Entry>
-
- <Entry DisplayName="Public Enums" Priority="100">
+ <Entry Priority="100" DisplayName="Public Enums">
<Entry.Match>
<And>
<Access Is="Public" />
<Kind Is="Enum" />
</And>
</Entry.Match>
-
<Entry.SortBy>
<Name />
</Entry.SortBy>
</Entry>
-
<Entry DisplayName="Static Fields and Constants">
<Entry.Match>
<Or>
@@ -215,17 +208,10 @@
</And>
</Or>
</Entry.Match>
-
<Entry.SortBy>
- <Kind>
- <Kind.Order>
- <DeclarationKind>Constant</DeclarationKind>
- <DeclarationKind>Field</DeclarationKind>
- </Kind.Order>
- </Kind>
+ <Kind Order="Constant Field" />
</Entry.SortBy>
</Entry>
-
<Entry DisplayName="Fields">
<Entry.Match>
<And>
@@ -235,23 +221,19 @@
</Not>
</And>
</Entry.Match>
-
<Entry.SortBy>
<Readonly />
<Name />
</Entry.SortBy>
</Entry>
-
<Entry DisplayName="Constructors">
<Entry.Match>
<Kind Is="Constructor" />
</Entry.Match>
-
<Entry.SortBy>
- <Static/>
+ <Static />
</Entry.SortBy>
</Entry>
-
<Entry DisplayName="Properties, Indexers">
<Entry.Match>
<Or>
@@ -260,30 +242,25 @@
</Or>
</Entry.Match>
</Entry>
-
- <Entry DisplayName="Interface Implementations" Priority="100">
+ <Entry Priority="100" DisplayName="Interface Implementations">
<Entry.Match>
<And>
<Kind Is="Member" />
<ImplementsInterface />
</And>
</Entry.Match>
-
<Entry.SortBy>
- <ImplementsInterface Immediate="true" />
+ <ImplementsInterface Immediate="True" />
</Entry.SortBy>
</Entry>
-
<Entry DisplayName="All other members" />
-
<Entry DisplayName="Nested Types">
<Entry.Match>
<Kind Is="Type" />
</Entry.Match>
</Entry>
</TypePattern>
-</Patterns>
-
+</Patterns>
<?xml version="1.0" encoding="utf-8" ?>
<!--
@@ -548,6 +525,8 @@ II.2.12 <HandlesEvent />
<Policy Inspect="True" Prefix="T" Suffix="" Style="AaBb" />
<Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
True
+ True
+ True
True
True
True
diff --git a/global.json b/global.json
new file mode 100644
index 000000000..b073e32a1
--- /dev/null
+++ b/global.json
@@ -0,0 +1,6 @@
+{
+ "projects": [ "src", "test" ],
+ "sdk": {
+ "version": "1.0.0-beta8"
+ }
+}
diff --git a/packages/repositories.config b/packages/repositories.config
deleted file mode 100644
index ef84a0768..000000000
--- a/packages/repositories.config
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Serilog.FullNetFx/LoggerConfigurationFullNetFxExtensions-net40.cs b/src/Serilog.FullNetFx/LoggerConfigurationFullNetFxExtensions-net40.cs
deleted file mode 100644
index e6774366a..000000000
--- a/src/Serilog.FullNetFx/LoggerConfigurationFullNetFxExtensions-net40.cs
+++ /dev/null
@@ -1,279 +0,0 @@
-// Copyright 2014 Serilog Contributors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-using System;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Threading;
-using Serilog.Configuration;
-using Serilog.Debugging;
-using Serilog.Enrichers;
-using Serilog.Events;
-using Serilog.Formatting.Display;
-using Serilog.Formatting.Raw;
-using Serilog.Settings.AppSettings;
-using Serilog.Sinks.DiagnosticTrace;
-using Serilog.Sinks.IOFile;
-using Serilog.Sinks.RollingFile;
-using Serilog.Sinks.SystemConsole;
-
-namespace Serilog
-{
- ///
- /// Extends to add Full .NET Framework
- /// capabilities.
- ///
- public static class LoggerConfigurationFullNetFxExtensions
- {
- const string DefaultOutputTemplate = "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] {Message}{NewLine}{Exception}";
- const string DefaultConsoleOutputTemplate = "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level}] {Message}{NewLine}{Exception}";
- const long DefaultFileSizeLimitBytes = 1L * 1024 * 1024 * 1024;
- const int DefaultRetainedFileCountLimit = 31; // A long month of logs
-
- ///
- /// Writes log events to .
- ///
- /// Logger sink configuration.
- /// The minimum level for
- /// events passed through the sink.
- /// A message template describing the format used to write to the sink.
- /// the default is "{Timestamp} [{Level}] {Message}{NewLine}{Exception}".
- /// Supplies culture-specific formatting information, or null.
- /// Configuration object allowing method chaining.
- public static LoggerConfiguration Console(
- this LoggerSinkConfiguration sinkConfiguration,
- LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
- string outputTemplate = DefaultConsoleOutputTemplate,
- IFormatProvider formatProvider = null)
- {
- if (sinkConfiguration == null) throw new ArgumentNullException("sinkConfiguration");
- if (outputTemplate == null) throw new ArgumentNullException("outputTemplate");
- var formatter = new MessageTemplateTextFormatter(outputTemplate, formatProvider);
- return sinkConfiguration.Sink(new ConsoleSink(formatter), restrictedToMinimumLevel);
- }
-
- ///
- /// Writes log events to , using color to differentiate
- /// between levels.
- ///
- /// Logger sink configuration.
- /// The minimum level for
- /// events passed through the sink.
- /// A message template describing the format used to write to the sink.
- /// the default is "{Timestamp} [{Level}] {Message}{NewLine}{Exception}".
- /// Supplies culture-specific formatting information, or null.
- /// Configuration object allowing method chaining.
- public static LoggerConfiguration ColoredConsole(
- this LoggerSinkConfiguration sinkConfiguration,
- LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
- string outputTemplate = DefaultConsoleOutputTemplate,
- IFormatProvider formatProvider = null)
- {
- if (sinkConfiguration == null) throw new ArgumentNullException("sinkConfiguration");
- if (outputTemplate == null) throw new ArgumentNullException("outputTemplate");
- return sinkConfiguration.Sink(new ColoredConsoleSink(outputTemplate, formatProvider), restrictedToMinimumLevel);
- }
-
- ///
- /// Write log events in a simple text dump format to the specified file.
- ///
- /// Logger sink configuration.
- /// Path to the dump file.
- /// The minimum level for
- /// events passed through the sink.
- /// Configuration object allowing method chaining.
- [Obsolete("Please use WriteTo.Sink(new FileSink(path, new RawFormatter(), null)) instead", true), EditorBrowsable(EditorBrowsableState.Never)]
- public static LoggerConfiguration DumpFile(
- this LoggerSinkConfiguration sinkConfiguration,
- string path,
- LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum)
- {
- if (sinkConfiguration == null) throw new ArgumentNullException("sinkConfiguration");
- if (path == null) throw new ArgumentNullException("path");
- return sinkConfiguration.Sink(new FileSink(path, new RawFormatter(), null), restrictedToMinimumLevel);
- }
-
- ///
- /// Write log events to the specified file.
- ///
- /// Logger sink configuration.
- /// Path to the file.
- /// The minimum level for
- /// events passed through the sink.
- /// Supplies culture-specific formatting information, or null.
- /// A message template describing the format used to write to the sink.
- /// the default is "{Timestamp} [{Level}] {Message}{NewLine}{Exception}".
- /// The maximum size, in bytes, to which a log file will be allowed to grow.
- /// For unrestricted growth, pass null. The default is 1 GB.
- /// Configuration object allowing method chaining.
- /// The file will be written using the UTF-8 character set.
- public static LoggerConfiguration File(
- this LoggerSinkConfiguration sinkConfiguration,
- string path,
- LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
- string outputTemplate = DefaultOutputTemplate,
- IFormatProvider formatProvider = null,
- long? fileSizeLimitBytes = DefaultFileSizeLimitBytes)
- {
- if (sinkConfiguration == null) throw new ArgumentNullException("sinkConfiguration");
- if (outputTemplate == null) throw new ArgumentNullException("outputTemplate");
- var formatter = new MessageTemplateTextFormatter(outputTemplate, formatProvider);
-
- FileSink sink;
- try
- {
- sink = new FileSink(path, formatter, fileSizeLimitBytes);
- }
- catch (ArgumentException)
- {
- throw;
- }
- catch (Exception ex)
- {
- SelfLog.WriteLine("Unable to open file sink for {0}: {1}", path, ex);
- return sinkConfiguration.Sink(new NullSink());
- }
-
- return sinkConfiguration.Sink(sink, restrictedToMinimumLevel);
- }
-
- ///
- /// Write log events to a series of files. Each file will be named according to
- /// the date of the first log entry written to it. Only simple date-based rolling is
- /// currently supported.
- ///
- /// Logger sink configuration.
- /// String describing the location of the log files,
- /// with {Date} in the place of the file date. E.g. "Logs\myapp-{Date}.log" will result in log
- /// files such as "Logs\myapp-2013-10-20.log", "Logs\myapp-2013-10-21.log" and so on.
- /// The minimum level for
- /// events passed through the sink.
- /// A message template describing the format used to write to the sink.
- /// the default is "{Timestamp} [{Level}] {Message}{NewLine}{Exception}".
- /// Supplies culture-specific formatting information, or null.
- /// The maximum size, in bytes, to which any single log file will be allowed to grow.
- /// For unrestricted growth, pass null. The default is 1 GB.
- /// The maximum number of log files that will be retained,
- /// including the current log file. For unlimited retention, pass null. The default is 31.
- /// Configuration object allowing method chaining.
- /// The file will be written using the UTF-8 character set.
- public static LoggerConfiguration RollingFile(
- this LoggerSinkConfiguration sinkConfiguration,
- string pathFormat,
- LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
- string outputTemplate = DefaultOutputTemplate,
- IFormatProvider formatProvider = null,
- long? fileSizeLimitBytes = DefaultFileSizeLimitBytes,
- int? retainedFileCountLimit = DefaultRetainedFileCountLimit)
- {
- if (sinkConfiguration == null) throw new ArgumentNullException("sinkConfiguration");
- if (outputTemplate == null) throw new ArgumentNullException("outputTemplate");
- var formatter = new MessageTemplateTextFormatter(outputTemplate, formatProvider);
- var sink = new RollingFileSink(pathFormat, formatter, fileSizeLimitBytes, retainedFileCountLimit);
- return sinkConfiguration.Sink(sink, restrictedToMinimumLevel);
- }
-
- ///
- /// Write log events to the .
- ///
- /// Logger sink configuration.
- /// The minimum level for
- /// events passed through the sink.
- /// A message template describing the format used to write to the sink.
- /// the default is "{Timestamp} [{Level}] {Message}{NewLine}{Exception}".
- /// Supplies culture-specific formatting information, or null.
- /// Configuration object allowing method chaining.
- public static LoggerConfiguration Trace(
- this LoggerSinkConfiguration sinkConfiguration,
- LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
- string outputTemplate = DefaultOutputTemplate,
- IFormatProvider formatProvider = null)
- {
- if (sinkConfiguration == null) throw new ArgumentNullException("sinkConfiguration");
- if (outputTemplate == null) throw new ArgumentNullException("outputTemplate");
- var formatter = new MessageTemplateTextFormatter(outputTemplate, formatProvider);
- return sinkConfiguration.Sink(new DiagnosticTraceSink(formatter), restrictedToMinimumLevel);
- }
-
- ///
- /// Enrich log events with properties from .
- ///
- /// Logger enrichment configuration.
- /// Configuration object allowing method chaining.
- ///
-#if !ASPNETCORE50
- public static LoggerConfiguration FromLogContext(
- this LoggerEnrichmentConfiguration enrichmentConfiguration)
- {
- if (enrichmentConfiguration == null) throw new ArgumentNullException("enrichmentConfiguration");
- return enrichmentConfiguration.With();
- }
-#endif
-
- ///
- /// Enrich log events with a ThreadId property containing the current .
- ///
- /// Logger enrichment configuration.
- /// Configuration object allowing method chaining.
- ///
- public static LoggerConfiguration WithThreadId(
- this LoggerEnrichmentConfiguration enrichmentConfiguration)
- {
- if (enrichmentConfiguration == null) throw new ArgumentNullException("enrichmentConfiguration");
- return enrichmentConfiguration.With();
- }
-
- ///
- /// Enrich log events with a ProcessId property containing the current .
- ///
- /// Logger enrichment configuration.
- /// Configuration object allowing method chaining.
- public static LoggerConfiguration WithProcessId(
- this LoggerEnrichmentConfiguration enrichmentConfiguration)
- {
- if (enrichmentConfiguration == null) throw new ArgumentNullException("enrichmentConfiguration");
- return enrichmentConfiguration.With();
- }
-
- ///
- /// Enrich log events with a MachineName property containing the current .
- ///
- /// Logger enrichment configuration.
- /// Configuration object allowing method chaining.
- public static LoggerConfiguration WithMachineName(
- this LoggerEnrichmentConfiguration enrichmentConfiguration)
- {
- if (enrichmentConfiguration == null) throw new ArgumentNullException("enrichmentConfiguration");
- return enrichmentConfiguration.With();
- }
-
-
- ///
- /// Reads the <appSettings> element of App.config or Web.config, searching for for keys
- /// that look like: serilog:*
, which are used to configure
- /// the logger. To add a sink, use a key like serilog:write-to:File.path
for
- /// each parameter to the sink's configuration method. To add an additional assembly
- /// containing sinks, use serilog:using
. To set the level use
- /// serilog:minimum-level
.
- ///
- /// Logger setting configuration
- /// An object allowing configuration to continue.
- public static LoggerConfiguration AppSettings(
- this LoggerSettingsConfiguration settingConfiguration)
- {
- if (settingConfiguration == null) throw new ArgumentNullException("settingConfiguration");
- return settingConfiguration.Settings(new AppSettingsSettings());
- }
- }
-}
diff --git a/src/Serilog.FullNetFx/Properties/AssemblyInfo.cs b/src/Serilog.FullNetFx/Properties/AssemblyInfo.cs
deleted file mode 100644
index daca6b6d9..000000000
--- a/src/Serilog.FullNetFx/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-
-[assembly: AssemblyTitle("Serilog.FullNetFx")]
-[assembly: AssemblyDescription("Serilog Logging Library Full .NET Framework Support")]
-[assembly: AssemblyCopyright("Copyright © Serilog Contributors 2013")]
-
-#if !ASPNETCORE50
-[assembly: InternalsVisibleTo("Serilog.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100fb8d13fd344a1c" +
- "6fe0fe83ef33c1080bf30690765bc6eb0df26ebfdf8f21670c64265b30db09f73a0dea5b3db4c9" +
- "d18dbf6d5a25af5ce9016f281014d79dc3b4201ac646c451830fc7e61a2dfd633d34c39f87b818" +
- "94191652df5ac63cc40c77f3542f702bda692e6e8a9158353df189007a49da0f3cfd55eb250066" +
- "b19485ec")]
-#else
-[assembly: InternalsVisibleTo("Serilog.Tests")]
-#endif
\ No newline at end of file
diff --git a/src/Serilog.FullNetFx/Serilog.FullNetFx-net40.csproj b/src/Serilog.FullNetFx/Serilog.FullNetFx-net40.csproj
deleted file mode 100644
index f70eb219e..000000000
--- a/src/Serilog.FullNetFx/Serilog.FullNetFx-net40.csproj
+++ /dev/null
@@ -1,93 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {7A9E1095-167D-402A-B43D-B36B97FF183D}
- Library
- Properties
- Serilog
- Serilog.FullNetFx
- v4.0
- 512
- Client
-
-
- true
- full
- false
- bin40\Debug\
- DEBUG;TRACE
- prompt
- 4
- true
- bin40\Debug\Serilog.FullNetFx.XML
-
-
- pdbonly
- true
- bin40\Release\
- TRACE
- prompt
- 4
- true
- bin40\Release\Serilog.FullNetFx.XML
-
-
- true
-
-
- ..\..\assets\Serilog.snk
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Properties\CommonAssemblyInfo.cs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Serilog.snk
-
-
-
-
-
-
-
-
-
-
- {0915dbd9-0f7c-4439-8d9e-74c3d579b219}
- Serilog-net40
-
-
-
-
\ No newline at end of file
diff --git a/src/Serilog.FullNetFx/Serilog.FullNetFx.csproj b/src/Serilog.FullNetFx/Serilog.FullNetFx.csproj
deleted file mode 100644
index 7e418021c..000000000
--- a/src/Serilog.FullNetFx/Serilog.FullNetFx.csproj
+++ /dev/null
@@ -1,88 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {7A9E1095-167D-402A-B43D-B36B97FF183D}
- Library
- Properties
- Serilog
- Serilog.FullNetFx
- v4.5
- 512
-
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
- true
- bin\Debug\Serilog.FullNetFx.XML
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
- true
- bin\Release\Serilog.FullNetFx.XML
-
-
- true
-
-
- ..\..\assets\Serilog.snk
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Properties\CommonAssemblyInfo.cs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Serilog.snk
-
-
-
-
- {0915dbd9-0f7c-4439-8d9e-74c3d579b219}
- Serilog
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Serilog.FullNetFx/Sinks/PeriodicBatching/PeriodicBatchingSink-net40.cs b/src/Serilog.FullNetFx/Sinks/PeriodicBatching/PeriodicBatchingSink-net40.cs
deleted file mode 100644
index fdc99a348..000000000
--- a/src/Serilog.FullNetFx/Sinks/PeriodicBatching/PeriodicBatchingSink-net40.cs
+++ /dev/null
@@ -1,219 +0,0 @@
-// Copyright 2014 Serilog Contributors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-using System;
-using System.Collections.Concurrent;
-using System.Collections.Generic;
-using System.Threading;
-using Serilog.Core;
-using Serilog.Debugging;
-using Serilog.Events;
-
-namespace Serilog.Sinks.PeriodicBatching
-{
- ///
- /// Base class for sinks that log events in batches. Batching is
- /// triggered asynchronously on a timer.
- ///
- ///
- /// To avoid unbounded memory growth, events are discarded after attempting
- /// to send a batch, regardless of whether the batch succeeded or not. Implementers
- /// that want to change this behavior need to either implement from scratch, or
- /// embed retry logic in the batch emitting functions.
- ///
- public abstract class PeriodicBatchingSink : ILogEventSink, IDisposable
- {
- readonly int _batchSizeLimit;
- readonly ConcurrentQueue _queue;
- readonly BatchedConnectionStatus _status;
- readonly Queue _waitingBatch = new Queue();
-
- readonly object _stateLock = new object();
- readonly Timer _timer;
- bool _unloading;
- bool _started;
-
- ///
- /// Construct a sink posting to the specified database.
- ///
- /// The maximum number of events to include in a single batch.
- /// The time to wait between checking for event batches.
- protected PeriodicBatchingSink(int batchSizeLimit, TimeSpan period)
- {
- _batchSizeLimit = batchSizeLimit;
- _queue = new ConcurrentQueue();
- _timer = new Timer(s => OnTick());
- _status = new BatchedConnectionStatus(period);
-
- AppDomain.CurrentDomain.DomainUnload += OnAppDomainUnloading;
- AppDomain.CurrentDomain.ProcessExit += OnAppDomainUnloading;
- AppDomain.CurrentDomain.UnhandledException += OnAppDomainUnloading;
- }
-
- void OnAppDomainUnloading(object sender, EventArgs args)
- {
- var eventArgs = args as UnhandledExceptionEventArgs;
- if (eventArgs != null && !eventArgs.IsTerminating)
- return;
-
- CloseAndFlush();
- }
-
- void CloseAndFlush()
- {
- lock (_stateLock)
- {
- if (!_started || _unloading)
- return;
-
- _unloading = true;
- }
-
- AppDomain.CurrentDomain.DomainUnload -= OnAppDomainUnloading;
- AppDomain.CurrentDomain.ProcessExit -= OnAppDomainUnloading;
- AppDomain.CurrentDomain.UnhandledException -= OnAppDomainUnloading;
-
- var wh = new ManualResetEvent(false);
- if (_timer.Dispose(wh))
- wh.WaitOne();
-
- OnTick();
- }
-
- ///
- /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
- ///
- /// 2
- public void Dispose()
- {
- Dispose(true);
- }
-
- ///
- /// Free resources held by the sink.
- ///
- /// If true, called because the object is being disposed; if false,
- /// the object is being disposed from the finalizer.
- protected virtual void Dispose(bool disposing)
- {
- if (!disposing) return;
- CloseAndFlush();
- }
-
- ///
- /// Emit a batch of log events, running to completion synchronously.
- ///
- /// The events to emit.
- protected abstract void EmitBatch(IEnumerable events);
-
- void OnTick()
- {
- try
- {
- do
- {
- LogEvent next;
- while (_waitingBatch.Count < _batchSizeLimit &&
- _queue.TryDequeue(out next))
- {
- if (CanInclude(next))
- _waitingBatch.Enqueue(next);
- }
-
- if (_waitingBatch.Count == 0)
- {
- OnEmptyBatch();
- return;
- }
-
- EmitBatch(_waitingBatch);
- _waitingBatch.Clear();
- _status.MarkSuccess();
- }
- while (true);
- }
- catch (Exception ex)
- {
- SelfLog.WriteLine("Exception while emitting periodic batch from {0}: {1}", this, ex);
- _status.MarkFailure();
- }
- finally
- {
- if (_status.ShouldDropBatch)
- _waitingBatch.Clear();
-
- if (_status.ShouldDropQueue)
- {
- LogEvent evt;
- while (_queue.TryDequeue(out evt)) { }
- }
-
- lock (_stateLock)
- {
- if (!_unloading)
- _timer.Change(_status.NextInterval, TimeSpan.FromMilliseconds(-1));
- }
- }
- }
-
- ///
- /// Emit the provided log event to the sink. If the sink is being disposed or
- /// the app domain unloaded, then the event is ignored.
- ///
- /// Log event to emit.
- /// The event is null.
- ///
- /// The sink implements the contract that any events whose Emit() method has
- /// completed at the time of sink disposal will be flushed (or attempted to,
- /// depending on app domain state).
- ///
- public void Emit(LogEvent logEvent)
- {
- if (logEvent == null) throw new ArgumentNullException("logEvent");
-
- lock (_stateLock)
- {
- if (_unloading) return;
- if (!_started)
- {
- // Special handling to try to get the first event across as quickly
- // as possible to show we're alive!
- _started = true;
- _timer.Change(TimeSpan.Zero, TimeSpan.FromMilliseconds(-1));
- }
- }
-
- _queue.Enqueue(logEvent);
- }
-
- ///
- /// Determine whether a queued log event should be included in the batch. If
- /// an override returns false, the event will be dropped.
- ///
- ///
- ///
- protected virtual bool CanInclude(LogEvent evt)
- {
- return true;
- }
-
- ///
- /// Allows derived sinks to perform periodic work without requiring additional threads
- /// or timers (thus avoiding additional flush/shut-down complexity).
- ///
- protected virtual void OnEmptyBatch()
- {
- }
- }
-}
diff --git a/src/Serilog.FullNetFx/Sinks/SystemConsole/ColoredConsoleSink-net40.cs b/src/Serilog.FullNetFx/Sinks/SystemConsole/ColoredConsoleSink-net40.cs
deleted file mode 100644
index 28e679143..000000000
--- a/src/Serilog.FullNetFx/Sinks/SystemConsole/ColoredConsoleSink-net40.cs
+++ /dev/null
@@ -1,170 +0,0 @@
-// Copyright 2013 Serilog Contributors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-using System;
-using System.IO;
-using Serilog.Core;
-using Serilog.Events;
-using System.Collections.Generic;
-using Serilog.Formatting.Display;
-using Serilog.Parsing;
-
-namespace Serilog.Sinks.SystemConsole
-{
- class ColoredConsoleSink : ILogEventSink
- {
- readonly IFormatProvider _formatProvider;
-
- class Palette
- {
- public ConsoleColor Base { get; set; }
- public ConsoleColor BaseText { get; set; }
- public ConsoleColor Highlight { get; set; }
- public ConsoleColor HighlightText { get; set; }
- }
-
- static readonly Palette DefaultPalette = new Palette { Base = ConsoleColor.Black, BaseText = ConsoleColor.Gray,
- Highlight = ConsoleColor.DarkGray, HighlightText = ConsoleColor.Gray };
-
- static readonly IDictionary LevelPalettes = new Dictionary
- {
- { LogEventLevel.Verbose, new Palette { Base = ConsoleColor.Black, BaseText = ConsoleColor.DarkGray,
- Highlight = ConsoleColor.Black, HighlightText = ConsoleColor.Gray } },
- { LogEventLevel.Debug, new Palette { Base = ConsoleColor.Black, BaseText = ConsoleColor.Gray,
- Highlight = ConsoleColor.Black, HighlightText = ConsoleColor.White } },
- { LogEventLevel.Information, new Palette { Base = ConsoleColor.Black, BaseText = ConsoleColor.White,
- Highlight = ConsoleColor.DarkBlue, HighlightText = ConsoleColor.White } },
- { LogEventLevel.Warning, new Palette { Base = ConsoleColor.Black, BaseText = ConsoleColor.Yellow,
- Highlight = ConsoleColor.DarkYellow, HighlightText = ConsoleColor.White } },
- { LogEventLevel.Error, new Palette { Base = ConsoleColor.Black, BaseText = ConsoleColor.Red,
- Highlight = ConsoleColor.Red, HighlightText = ConsoleColor.White } },
- { LogEventLevel.Fatal, new Palette { Base = ConsoleColor.DarkRed, BaseText = ConsoleColor.White,
- Highlight = ConsoleColor.Red, HighlightText = ConsoleColor.White } }
- };
-
- readonly object _syncRoot = new object();
- readonly MessageTemplate _outputTemplate;
-
- public ColoredConsoleSink(string outputTemplate, IFormatProvider formatProvider)
- {
- if (outputTemplate == null) throw new ArgumentNullException("outputTemplate");
- _outputTemplate = new MessageTemplateParser().Parse(outputTemplate);
- _formatProvider = formatProvider;
- }
-
- const string StackFrameLinePrefix = " ";
-
- public void Emit(LogEvent logEvent)
- {
- if (logEvent == null) throw new ArgumentNullException("logEvent");
-
- var outputProperties = OutputProperties.GetOutputProperties(logEvent);
- var palette = GetPalette(logEvent.Level);
- var output = Console.Out;
-
- lock (_syncRoot)
- {
- try
- {
- foreach (var outputToken in _outputTemplate.Tokens)
- {
- var propertyToken = outputToken as PropertyToken;
- if (propertyToken == null)
- {
- RenderOutputToken(palette, outputToken, outputProperties, output);
- }
- else switch (propertyToken.PropertyName)
- {
- case OutputProperties.MessagePropertyName:
- RenderMessageToken(logEvent, palette, output);
- break;
- case OutputProperties.ExceptionPropertyName:
- RenderExceptionToken(palette, propertyToken, outputProperties, output);
- break;
- default:
- RenderOutputToken(palette, outputToken, outputProperties, output);
- break;
- }
- }
- }
- finally { Console.ResetColor(); }
- }
- }
-
- void RenderExceptionToken(Palette palette, MessageTemplateToken outputToken, IDictionary outputProperties, TextWriter output)
- {
- var sw = new StringWriter();
- outputToken.Render(outputProperties, sw, _formatProvider);
- var lines = new StringReader(sw.ToString());
- string nextLine;
- while ((nextLine = lines.ReadLine()) != null)
- {
- if (nextLine.StartsWith(StackFrameLinePrefix))
- SetBaseColors(palette);
- else
- SetHighlightColors(palette);
- output.WriteLine(nextLine);
- }
- }
-
- void RenderMessageToken(LogEvent logEvent, Palette palette, TextWriter output)
- {
- foreach (var messageToken in logEvent.MessageTemplate.Tokens)
- {
- var messagePropertyToken = messageToken as PropertyToken;
- if (messagePropertyToken != null)
- {
- SetHighlightColors(palette);
- messageToken.Render(logEvent.Properties, output, _formatProvider);
- }
- else
- {
- SetBaseColors(palette);
- messageToken.Render(logEvent.Properties, output, _formatProvider);
- }
- }
- }
-
- void RenderOutputToken(Palette palette, MessageTemplateToken outputToken, IDictionary outputProperties, TextWriter output)
- {
- SetBaseColors(palette);
- outputToken.Render(outputProperties, output, _formatProvider);
- }
-
- static Palette GetPalette(LogEventLevel level)
- {
- Palette palette;
- if (!LevelPalettes.TryGetValue(level, out palette))
- palette = DefaultPalette;
-
- return palette;
- }
-
- static void SetBaseColors(Palette palette)
- {
- SetColors(palette.Base, palette.BaseText);
- }
-
- static void SetHighlightColors(Palette palette)
- {
- SetColors(palette.Highlight, palette.HighlightText);
- }
-
- static void SetColors(ConsoleColor background, ConsoleColor foreground)
- {
- Console.BackgroundColor = background;
- Console.ForegroundColor = foreground;
- }
- }
-}
diff --git a/src/Serilog/Configuration/ILoggerSettings.cs b/src/Serilog/Configuration/ILoggerSettings.cs
index a5506e05d..4f7c50dcd 100644
--- a/src/Serilog/Configuration/ILoggerSettings.cs
+++ b/src/Serilog/Configuration/ILoggerSettings.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
diff --git a/src/Serilog/Configuration/LoggerDestructuringConfiguration.cs b/src/Serilog/Configuration/LoggerDestructuringConfiguration.cs
index 88af10d28..61c476e08 100644
--- a/src/Serilog/Configuration/LoggerDestructuringConfiguration.cs
+++ b/src/Serilog/Configuration/LoggerDestructuringConfiguration.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -34,9 +34,9 @@ internal LoggerDestructuringConfiguration(
Action addPolicy,
Action setMaximumDepth)
{
- if (loggerConfiguration == null) throw new ArgumentNullException("loggerConfiguration");
- if (addScalar == null) throw new ArgumentNullException("addScalar");
- if (addPolicy == null) throw new ArgumentNullException("addPolicy");
+ if (loggerConfiguration == null) throw new ArgumentNullException(nameof(loggerConfiguration));
+ if (addScalar == null) throw new ArgumentNullException(nameof(addScalar));
+ if (addPolicy == null) throw new ArgumentNullException(nameof(addPolicy));
_loggerConfiguration = loggerConfiguration;
_addScalar = addScalar;
_addPolicy = addPolicy;
@@ -51,7 +51,7 @@ internal LoggerDestructuringConfiguration(
/// Configuration object allowing method chaining.
public LoggerConfiguration AsScalar(Type scalarType)
{
- if (scalarType == null) throw new ArgumentNullException("scalarType");
+ if (scalarType == null) throw new ArgumentNullException(nameof(scalarType));
_addScalar(scalarType);
return _loggerConfiguration;
}
@@ -75,7 +75,7 @@ public LoggerConfiguration AsScalar()
// ReSharper disable once MemberCanBePrivate.Global
public LoggerConfiguration With(params IDestructuringPolicy[] destructuringPolicies)
{
- if (destructuringPolicies == null) throw new ArgumentNullException("destructuringPolicies");
+ if (destructuringPolicies == null) throw new ArgumentNullException(nameof(destructuringPolicies));
foreach (var destructuringPolicy in destructuringPolicies)
{
if (destructuringPolicy == null)
@@ -107,7 +107,7 @@ public LoggerConfiguration With()
///
public LoggerConfiguration ByTransforming(Func transformation)
{
- if (transformation == null) throw new ArgumentNullException("transformation");
+ if (transformation == null) throw new ArgumentNullException(nameof(transformation));
var policy = new ProjectedDestructuringPolicy(t => t == typeof(TValue),
o => transformation((TValue)o));
return With(policy);
@@ -123,7 +123,7 @@ public LoggerConfiguration ByTransforming(Func transform
///
public LoggerConfiguration ToMaximumDepth(int maximumDestructuringDepth)
{
- if (maximumDestructuringDepth < 0) throw new ArgumentOutOfRangeException("maximumDestructuringDepth");
+ if (maximumDestructuringDepth < 0) throw new ArgumentOutOfRangeException(nameof(maximumDestructuringDepth));
_setMaximumDepth(maximumDestructuringDepth);
return _loggerConfiguration;
}
diff --git a/src/Serilog/Configuration/LoggerEnrichmentConfiguration.cs b/src/Serilog/Configuration/LoggerEnrichmentConfiguration.cs
index 33d153c24..c7f0f9eb1 100644
--- a/src/Serilog/Configuration/LoggerEnrichmentConfiguration.cs
+++ b/src/Serilog/Configuration/LoggerEnrichmentConfiguration.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -30,8 +30,8 @@ internal LoggerEnrichmentConfiguration(
LoggerConfiguration loggerConfiguration,
Action addEnricher)
{
- if (loggerConfiguration == null) throw new ArgumentNullException("loggerConfiguration");
- if (addEnricher == null) throw new ArgumentNullException("addEnricher");
+ if (loggerConfiguration == null) throw new ArgumentNullException(nameof(loggerConfiguration));
+ if (addEnricher == null) throw new ArgumentNullException(nameof(addEnricher));
_loggerConfiguration = loggerConfiguration;
_addEnricher = addEnricher;
}
@@ -45,7 +45,7 @@ internal LoggerEnrichmentConfiguration(
/// Configuration object allowing method chaining.
public LoggerConfiguration With(params ILogEventEnricher[] enrichers)
{
- if (enrichers == null) throw new ArgumentNullException("enrichers");
+ if (enrichers == null) throw new ArgumentNullException(nameof(enrichers));
foreach (var logEventEnricher in enrichers)
{
if (logEventEnricher == null)
diff --git a/src/Serilog/Configuration/LoggerFilterConfiguration.cs b/src/Serilog/Configuration/LoggerFilterConfiguration.cs
index 4d5752e4c..a134b6ed1 100644
--- a/src/Serilog/Configuration/LoggerFilterConfiguration.cs
+++ b/src/Serilog/Configuration/LoggerFilterConfiguration.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -31,8 +31,8 @@ internal LoggerFilterConfiguration(
LoggerConfiguration loggerConfiguration,
Action addFilter)
{
- if (loggerConfiguration == null) throw new ArgumentNullException("loggerConfiguration");
- if (addFilter == null) throw new ArgumentNullException("addFilter");
+ if (loggerConfiguration == null) throw new ArgumentNullException(nameof(loggerConfiguration));
+ if (addFilter == null) throw new ArgumentNullException(nameof(addFilter));
_loggerConfiguration = loggerConfiguration;
_addFilter = addFilter;
}
@@ -45,7 +45,7 @@ internal LoggerFilterConfiguration(
/// Configuration object allowing method chaining.
public LoggerConfiguration With(params ILogEventFilter[] filters)
{
- if (filters == null) throw new ArgumentNullException("filters");
+ if (filters == null) throw new ArgumentNullException(nameof(filters));
foreach (var logEventFilter in filters)
{
if (logEventFilter == null)
diff --git a/src/Serilog/Configuration/LoggerMinimumLevelConfiguration.cs b/src/Serilog/Configuration/LoggerMinimumLevelConfiguration.cs
index ebe323688..2148957a0 100644
--- a/src/Serilog/Configuration/LoggerMinimumLevelConfiguration.cs
+++ b/src/Serilog/Configuration/LoggerMinimumLevelConfiguration.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -29,8 +29,8 @@ public class LoggerMinimumLevelConfiguration
internal LoggerMinimumLevelConfiguration(LoggerConfiguration loggerConfiguration, Action setMinimum, Action setLevelSwitch)
{
- if (loggerConfiguration == null) throw new ArgumentNullException("loggerConfiguration");
- if (setMinimum == null) throw new ArgumentNullException("setMinimum");
+ if (loggerConfiguration == null) throw new ArgumentNullException(nameof(loggerConfiguration));
+ if (setMinimum == null) throw new ArgumentNullException(nameof(setMinimum));
_loggerConfiguration = loggerConfiguration;
_setMinimum = setMinimum;
_setLevelSwitch = setLevelSwitch;
@@ -54,7 +54,7 @@ public LoggerConfiguration Is(LogEventLevel minimumLevel)
/// Configuration object allowing method chaining.
public LoggerConfiguration ControlledBy(LoggingLevelSwitch levelSwitch)
{
- if (levelSwitch == null) throw new ArgumentNullException("levelSwitch");
+ if (levelSwitch == null) throw new ArgumentNullException(nameof(levelSwitch));
_setLevelSwitch(levelSwitch);
return _loggerConfiguration;
}
diff --git a/src/Serilog/Configuration/LoggerSettingsConfiguration-net40.cs b/src/Serilog/Configuration/LoggerSettingsConfiguration-net40.cs
deleted file mode 100644
index 77b64f1f9..000000000
--- a/src/Serilog/Configuration/LoggerSettingsConfiguration-net40.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright 2015 Serilog Contributors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-using System;
-using System.Collections.Generic;
-using Serilog.Settings.KeyValuePairs;
-
-namespace Serilog.Configuration
-{
- ///
- /// Allows additional setting sources to drive the logger configuration.
- ///
- public class LoggerSettingsConfiguration
- {
- readonly LoggerConfiguration _loggerConfiguration;
-
- internal LoggerSettingsConfiguration(LoggerConfiguration loggerConfiguration)
- {
- if (loggerConfiguration == null) throw new ArgumentNullException("loggerConfiguration");
- _loggerConfiguration = loggerConfiguration;
- }
-
- ///
- /// Apply external settings to the logger configuration.
- ///
- /// Configuration object allowing method chaining.
- public LoggerConfiguration Settings(ILoggerSettings settings)
- {
- if (settings == null) throw new ArgumentNullException("settings");
-
- settings.Configure(_loggerConfiguration);
-
- return _loggerConfiguration;
- }
-
- ///
- /// Apply settings specified in the Serilog key-value setting format to the logger configuration.
- ///
- /// A list of key-value pairs describing logger settings.
- /// Configuration object allowing method chaining.
- public LoggerConfiguration KeyValuePairs(IEnumerable> settings)
- {
- if (settings == null) throw new ArgumentNullException("settings");
- return Settings(new KeyValuePairSettings(settings));
- }
- }
-}
diff --git a/src/Serilog/Configuration/LoggerSettingsConfiguration.cs b/src/Serilog/Configuration/LoggerSettingsConfiguration.cs
index 77b64f1f9..2d9485b1c 100644
--- a/src/Serilog/Configuration/LoggerSettingsConfiguration.cs
+++ b/src/Serilog/Configuration/LoggerSettingsConfiguration.cs
@@ -27,7 +27,7 @@ public class LoggerSettingsConfiguration
internal LoggerSettingsConfiguration(LoggerConfiguration loggerConfiguration)
{
- if (loggerConfiguration == null) throw new ArgumentNullException("loggerConfiguration");
+ if (loggerConfiguration == null) throw new ArgumentNullException(nameof(loggerConfiguration));
_loggerConfiguration = loggerConfiguration;
}
@@ -37,7 +37,7 @@ internal LoggerSettingsConfiguration(LoggerConfiguration loggerConfiguration)
/// Configuration object allowing method chaining.
public LoggerConfiguration Settings(ILoggerSettings settings)
{
- if (settings == null) throw new ArgumentNullException("settings");
+ if (settings == null) throw new ArgumentNullException(nameof(settings));
settings.Configure(_loggerConfiguration);
@@ -51,7 +51,7 @@ public LoggerConfiguration Settings(ILoggerSettings settings)
/// Configuration object allowing method chaining.
public LoggerConfiguration KeyValuePairs(IEnumerable> settings)
{
- if (settings == null) throw new ArgumentNullException("settings");
+ if (settings == null) throw new ArgumentNullException(nameof(settings));
return Settings(new KeyValuePairSettings(settings));
}
}
diff --git a/src/Serilog/Configuration/LoggerSinkConfiguration.cs b/src/Serilog/Configuration/LoggerSinkConfiguration.cs
index 3026728e2..c6fcfef6a 100644
--- a/src/Serilog/Configuration/LoggerSinkConfiguration.cs
+++ b/src/Serilog/Configuration/LoggerSinkConfiguration.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -13,9 +13,11 @@
// limitations under the License.
using System;
+using System.ComponentModel;
using System.IO;
using Serilog.Core;
using Serilog.Core.Sinks;
+using Serilog.Debugging;
using Serilog.Events;
using Serilog.Formatting.Display;
using Serilog.Sinks.IOTextWriter;
@@ -35,8 +37,8 @@ public class LoggerSinkConfiguration
internal LoggerSinkConfiguration(LoggerConfiguration loggerConfiguration, Action addSink)
{
- if (loggerConfiguration == null) throw new ArgumentNullException("loggerConfiguration");
- if (addSink == null) throw new ArgumentNullException("addSink");
+ if (loggerConfiguration == null) throw new ArgumentNullException(nameof(loggerConfiguration));
+ if (addSink == null) throw new ArgumentNullException(nameof(addSink));
_loggerConfiguration = loggerConfiguration;
_addSink = addSink;
}
@@ -48,13 +50,44 @@ internal LoggerSinkConfiguration(LoggerConfiguration loggerConfiguration, Action
/// The minimum level for
/// events passed through the sink.
/// Configuration object allowing method chaining.
+ /// Provided for binary compatibility for earlier versions,
+ /// should be removed in 2.0. Not marked obsolete because warnings
+ /// would be syntactically annoying to avoid.
+ [EditorBrowsable(EditorBrowsableState.Never)]
public LoggerConfiguration Sink(
ILogEventSink logEventSink,
- LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum)
+ LogEventLevel restrictedToMinimumLevel)
+ {
+ return Sink(logEventSink, restrictedToMinimumLevel, null);
+ }
+
+ ///
+ /// Write log events to the specified .
+ ///
+ /// The sink.
+ /// The minimum level for
+ /// events passed through the sink. Ignored when is specified.
+ /// A switch allowing the pass-through minimum level
+ /// to be changed at runtime.
+ /// Configuration object allowing method chaining.
+ public LoggerConfiguration Sink(
+ ILogEventSink logEventSink,
+ LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
+ // ReSharper disable once MethodOverloadWithOptionalParameter
+ LoggingLevelSwitch levelSwitch = null)
{
var sink = logEventSink;
- if (restrictedToMinimumLevel > LevelAlias.Minimum)
- sink = new RestrictedSink(sink, restrictedToMinimumLevel);
+ if (levelSwitch != null)
+ {
+ if (restrictedToMinimumLevel != LevelAlias.Minimum)
+ SelfLog.WriteLine("Sink {0} was configured with both a level switch and minimum level '{1}'; the minimum level will be ignored and the switch level used", sink, restrictedToMinimumLevel);
+
+ sink = new RestrictedSink(sink, levelSwitch);
+ }
+ else if (restrictedToMinimumLevel > LevelAlias.Minimum)
+ {
+ sink = new RestrictedSink(sink, new LoggingLevelSwitch(restrictedToMinimumLevel));
+ }
_addSink(sink);
return _loggerConfiguration;
@@ -65,12 +98,16 @@ public LoggerConfiguration Sink(
///
/// The sink.
/// The minimum level for
- /// events passed through the sink.
+ /// events passed through the sink. Ignored when is specified.
+ /// A switch allowing the pass-through minimum level
+ /// to be changed at runtime.
/// Configuration object allowing method chaining.
- public LoggerConfiguration Sink(LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum)
+ public LoggerConfiguration Sink(
+ LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
+ LoggingLevelSwitch levelSwitch = null)
where TSink : ILogEventSink, new()
{
- return Sink(new TSink(), restrictedToMinimumLevel);
+ return Sink(new TSink(), restrictedToMinimumLevel, levelSwitch);
}
///
@@ -79,7 +116,9 @@ public LoggerConfiguration Sink(LogEventLevel restrictedToMinimumLevel =
/// The text writer to write log events to.
/// Message template describing the output format.
/// The minimum level for
- /// events passed through the sink.
+ /// events passed through the sink. Ignored when is specified.
+ /// A switch allowing the pass-through minimum level
+ /// to be changed at runtime.
/// Configuration object allowing method chaining.
/// Supplies culture-specific formatting information, or null.
///
@@ -87,14 +126,15 @@ public LoggerConfiguration TextWriter(
TextWriter textWriter,
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
string outputTemplate = DefaultOutputTemplate,
- IFormatProvider formatProvider = null)
+ IFormatProvider formatProvider = null,
+ LoggingLevelSwitch levelSwitch = null)
{
- if (textWriter == null) throw new ArgumentNullException("textWriter");
- if (outputTemplate == null) throw new ArgumentNullException("outputTemplate");
+ 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 Sink(sink, restrictedToMinimumLevel);
+ return Sink(sink, restrictedToMinimumLevel, levelSwitch);
}
///
@@ -105,13 +145,16 @@ public LoggerConfiguration TextWriter(
///
/// An action that configures the sub-logger.
/// The minimum level for
- /// events passed through the sink.
+ /// events passed through the sink. Ignored when is specified.
+ /// A switch allowing the pass-through minimum level
+ /// to be changed at runtime.
/// Configuration object allowing method chaining.
public LoggerConfiguration Logger(
Action configureLogger,
- LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum)
+ LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
+ LoggingLevelSwitch levelSwitch = null)
{
- if (configureLogger == null) throw new ArgumentNullException("configureLogger");
+ if (configureLogger == null) throw new ArgumentNullException(nameof(configureLogger));
var lc = new LoggerConfiguration();
configureLogger(lc);
return Sink(new SecondaryLoggerSink(lc.CreateLogger(), attemptDispose: true), restrictedToMinimumLevel);
@@ -132,7 +175,7 @@ public LoggerConfiguration Logger(
ILogger logger,
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum)
{
- if (logger == null) throw new ArgumentNullException("logger");
+ if (logger == null) throw new ArgumentNullException(nameof(logger));
return Sink(new SecondaryLoggerSink(logger, attemptDispose: false), restrictedToMinimumLevel);
}
@@ -142,16 +185,19 @@ public LoggerConfiguration Logger(
/// An action that provides an observable
/// to which observers can subscribe.
/// The minimum level for
- /// events passed through the sink.
+ /// events passed through the sink. Ignored when is specified.
+ /// A switch allowing the pass-through minimum level
+ /// to be changed at runtime.
/// Configuration object allowing method chaining.
public LoggerConfiguration Observers(
Action> configureObservers,
- LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum)
+ LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
+ LoggingLevelSwitch levelSwitch = null)
{
- if (configureObservers == null) throw new ArgumentNullException("configureObservers");
+ if (configureObservers == null) throw new ArgumentNullException(nameof(configureObservers));
var observable = new ObservableSink();
configureObservers(observable);
- return Sink(observable, restrictedToMinimumLevel);
+ return Sink(observable, restrictedToMinimumLevel, levelSwitch);
}
}
}
diff --git a/src/Serilog.FullNetFx/Context/ImmutableStack.cs b/src/Serilog/Context/ImmutableStack.cs
similarity index 93%
rename from src/Serilog.FullNetFx/Context/ImmutableStack.cs
rename to src/Serilog/Context/ImmutableStack.cs
index 237cf2ef2..01d12f973 100644
--- a/src/Serilog.FullNetFx/Context/ImmutableStack.cs
+++ b/src/Serilog/Context/ImmutableStack.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#if !ASPNETCORE50
+#if !PROFILE259 && !DNXCORE50
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
@@ -40,7 +40,7 @@ public ImmutableStack(SerializationInfo info, StreamingContext context)
ImmutableStack(ImmutableStack under, T top)
{
- if (under == null) throw new ArgumentNullException("under");
+ if (under == null) throw new ArgumentNullException(nameof(under));
_under = under;
_count = under.Count + 1;
_top = top;
diff --git a/src/Serilog.FullNetFx/Context/LogContext.cs b/src/Serilog/Context/LogContext.cs
similarity index 98%
rename from src/Serilog.FullNetFx/Context/LogContext.cs
rename to src/Serilog/Context/LogContext.cs
index 21ed80f03..52f61af4c 100644
--- a/src/Serilog.FullNetFx/Context/LogContext.cs
+++ b/src/Serilog/Context/LogContext.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#if !ASPNETCORE50
+#if !PROFILE259 && !DNXCORE50
using System;
using System.Runtime.Remoting.Messaging;
using Serilog.Core;
@@ -89,7 +89,7 @@ public static IDisposable PushProperty(string name, object value, bool destructu
///
public static IDisposable PushProperties(params ILogEventEnricher[] properties)
{
- if (properties == null) throw new ArgumentNullException("properties");
+ if (properties == null) throw new ArgumentNullException(nameof(properties));
var stack = GetOrCreateEnricherStack();
var bookmark = new ContextStackBookmark(stack);
diff --git a/src/Serilog/Core/Constants.cs b/src/Serilog/Core/Constants.cs
index cce7dc064..bf1eec71c 100644
--- a/src/Serilog/Core/Constants.cs
+++ b/src/Serilog/Core/Constants.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
diff --git a/src/Serilog/Core/Enrichers/FixedPropertyEnricher.cs b/src/Serilog/Core/Enrichers/FixedPropertyEnricher.cs
index bd830c767..899493410 100644
--- a/src/Serilog/Core/Enrichers/FixedPropertyEnricher.cs
+++ b/src/Serilog/Core/Enrichers/FixedPropertyEnricher.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -23,13 +23,13 @@ class FixedPropertyEnricher : ILogEventEnricher
public FixedPropertyEnricher(LogEventProperty logEventProperty)
{
- if (logEventProperty == null) throw new ArgumentNullException("logEventProperty");
+ if (logEventProperty == null) throw new ArgumentNullException(nameof(logEventProperty));
_logEventProperty = logEventProperty;
}
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
{
- if (logEvent == null) throw new ArgumentNullException("logEvent");
+ if (logEvent == null) throw new ArgumentNullException(nameof(logEvent));
logEvent.AddPropertyIfAbsent(_logEventProperty);
}
}
diff --git a/src/Serilog/Core/Enrichers/PropertyEnricher.cs b/src/Serilog/Core/Enrichers/PropertyEnricher.cs
index 0319db8d1..35f5147a2 100644
--- a/src/Serilog/Core/Enrichers/PropertyEnricher.cs
+++ b/src/Serilog/Core/Enrichers/PropertyEnricher.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -39,7 +39,7 @@ public class PropertyEnricher : ILogEventEnricher
///
public PropertyEnricher(string name, object value, bool destructureObjects = false)
{
- if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Property name must not be null or empty.", "name");
+ if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Property name must not be null or empty.", nameof(name));
_name = name;
_value = value;
_destructureObjects = destructureObjects;
@@ -52,8 +52,8 @@ public PropertyEnricher(string name, object value, bool destructureObjects = fal
/// Factory for creating new properties to add to the event.
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
{
- if (logEvent == null) throw new ArgumentNullException("logEvent");
- if (propertyFactory == null) throw new ArgumentNullException("propertyFactory");
+ if (logEvent == null) throw new ArgumentNullException(nameof(logEvent));
+ if (propertyFactory == null) throw new ArgumentNullException(nameof(propertyFactory));
var property = propertyFactory.CreateProperty(_name, _value, _destructureObjects);
logEvent.AddPropertyIfAbsent(property);
}
diff --git a/src/Serilog/Core/Filters/DelegateFilter.cs b/src/Serilog/Core/Filters/DelegateFilter.cs
index b076e1a92..76a976337 100644
--- a/src/Serilog/Core/Filters/DelegateFilter.cs
+++ b/src/Serilog/Core/Filters/DelegateFilter.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -23,13 +23,13 @@ class DelegateFilter : ILogEventFilter
public DelegateFilter(Func isEnabled)
{
- if (isEnabled == null) throw new ArgumentNullException("isEnabled");
+ if (isEnabled == null) throw new ArgumentNullException(nameof(isEnabled));
_isEnabled = isEnabled;
}
public bool IsEnabled(LogEvent logEvent)
{
- if (logEvent == null) throw new ArgumentNullException("logEvent");
+ if (logEvent == null) throw new ArgumentNullException(nameof(logEvent));
return _isEnabled(logEvent);
}
}
diff --git a/src/Serilog/Core/IDestructuringPolicy.cs b/src/Serilog/Core/IDestructuringPolicy.cs
index 4e9e57d6d..774cb9969 100644
--- a/src/Serilog/Core/IDestructuringPolicy.cs
+++ b/src/Serilog/Core/IDestructuringPolicy.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
diff --git a/src/Serilog/Core/ILogEventEnricher.cs b/src/Serilog/Core/ILogEventEnricher.cs
index 6cd5f7680..53f76834e 100644
--- a/src/Serilog/Core/ILogEventEnricher.cs
+++ b/src/Serilog/Core/ILogEventEnricher.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
diff --git a/src/Serilog/Core/ILogEventFilter.cs b/src/Serilog/Core/ILogEventFilter.cs
index cbf793883..5fcdda2b3 100644
--- a/src/Serilog/Core/ILogEventFilter.cs
+++ b/src/Serilog/Core/ILogEventFilter.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
diff --git a/src/Serilog/Core/ILogEventPropertyFactory.cs b/src/Serilog/Core/ILogEventPropertyFactory.cs
index 2340df6a0..56d707b37 100644
--- a/src/Serilog/Core/ILogEventPropertyFactory.cs
+++ b/src/Serilog/Core/ILogEventPropertyFactory.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
diff --git a/src/Serilog/Core/ILogEventSink.cs b/src/Serilog/Core/ILogEventSink.cs
index cf917d189..eee6b9e13 100644
--- a/src/Serilog/Core/ILogEventSink.cs
+++ b/src/Serilog/Core/ILogEventSink.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
diff --git a/src/Serilog/Core/IMessageTemplateParser.cs b/src/Serilog/Core/IMessageTemplateParser.cs
index 0cdf8fdfa..63ad9ed03 100644
--- a/src/Serilog/Core/IMessageTemplateParser.cs
+++ b/src/Serilog/Core/IMessageTemplateParser.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
diff --git a/src/Serilog/Core/LoggingLevelSwitch.cs b/src/Serilog/Core/LoggingLevelSwitch.cs
index 8a1e1ef13..34a058b65 100644
--- a/src/Serilog/Core/LoggingLevelSwitch.cs
+++ b/src/Serilog/Core/LoggingLevelSwitch.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
diff --git a/src/Serilog/Core/Pipeline/Logger.cs b/src/Serilog/Core/Pipeline/Logger.cs
index 732c4089a..681402f93 100644
--- a/src/Serilog/Core/Pipeline/Logger.cs
+++ b/src/Serilog/Core/Pipeline/Logger.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -65,8 +65,8 @@ public Logger(
Action dispose = null,
LoggingLevelSwitch levelSwitch = null)
{
- if (sink == null) throw new ArgumentNullException("sink");
- if (enrichers == null) throw new ArgumentNullException("enrichers");
+ if (sink == null) throw new ArgumentNullException(nameof(sink));
+ if (enrichers == null) throw new ArgumentNullException(nameof(enrichers));
_messageTemplateProcessor = messageTemplateProcessor;
_minimumLevel = minimumLevel;
@@ -96,7 +96,7 @@ public ILogger ForContext(string propertyName, object value, bool destructureObj
public ILogger ForContext(Type source)
{
- if (source == null) throw new ArgumentNullException("source");
+ if (source == null) throw new ArgumentNullException(nameof(source));
return ForContext(Constants.SourceContextPropertyName, source.FullName);
}
@@ -150,7 +150,7 @@ public void Write(LogEvent logEvent)
public void Emit(LogEvent logEvent)
{
- if (logEvent == null) throw new ArgumentNullException("logEvent");
+ if (logEvent == null) throw new ArgumentNullException(nameof(logEvent));
Write(logEvent);
}
diff --git a/src/Serilog/Core/Pipeline/MessageTemplateCache.cs b/src/Serilog/Core/Pipeline/MessageTemplateCache.cs
index e53d527b2..c369614d9 100644
--- a/src/Serilog/Core/Pipeline/MessageTemplateCache.cs
+++ b/src/Serilog/Core/Pipeline/MessageTemplateCache.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -29,13 +29,13 @@ class MessageTemplateCache : IMessageTemplateParser
public MessageTemplateCache(IMessageTemplateParser innerParser)
{
- if (innerParser == null) throw new ArgumentNullException("innerParser");
+ if (innerParser == null) throw new ArgumentNullException(nameof(innerParser));
_innerParser = innerParser;
}
public MessageTemplate Parse(string messageTemplate)
{
- if (messageTemplate == null) throw new ArgumentNullException("messageTemplate");
+ if (messageTemplate == null) throw new ArgumentNullException(nameof(messageTemplate));
if (messageTemplate.Length > MaxCachedTemplateLength)
return _innerParser.Parse(messageTemplate);
diff --git a/src/Serilog/Core/Pipeline/SilentLogger.cs b/src/Serilog/Core/Pipeline/SilentLogger.cs
index 0abe3bbb7..114b8845e 100644
--- a/src/Serilog/Core/Pipeline/SilentLogger.cs
+++ b/src/Serilog/Core/Pipeline/SilentLogger.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
diff --git a/src/Serilog/Core/Sinks/FilteringSink.cs b/src/Serilog/Core/Sinks/FilteringSink.cs
index 645f20d40..c2fe7cb71 100644
--- a/src/Serilog/Core/Sinks/FilteringSink.cs
+++ b/src/Serilog/Core/Sinks/FilteringSink.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -26,8 +26,8 @@ class FilteringSink : ILogEventSink
public FilteringSink(ILogEventSink sink, IEnumerable filters)
{
- if (sink == null) throw new ArgumentNullException("sink");
- if (filters == null) throw new ArgumentNullException("filters");
+ if (sink == null) throw new ArgumentNullException(nameof(sink));
+ if (filters == null) throw new ArgumentNullException(nameof(filters));
_sink = sink;
_filters = filters.ToArray();
}
diff --git a/src/Serilog/Core/Sinks/RestrictedSink.cs b/src/Serilog/Core/Sinks/RestrictedSink.cs
index ee082c93b..d1e1a6933 100644
--- a/src/Serilog/Core/Sinks/RestrictedSink.cs
+++ b/src/Serilog/Core/Sinks/RestrictedSink.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -20,20 +20,21 @@ namespace Serilog.Core.Sinks
class RestrictedSink : ILogEventSink
{
readonly ILogEventSink _sink;
- readonly LogEventLevel _restrictedMinimumLevel;
+ readonly LoggingLevelSwitch _levelSwitch;
- public RestrictedSink(ILogEventSink sink, LogEventLevel restrictedMinimumLevel)
+ public RestrictedSink(ILogEventSink sink, LoggingLevelSwitch levelSwitch)
{
- if (sink == null) throw new ArgumentNullException("sink");
+ if (sink == null) throw new ArgumentNullException(nameof(sink));
+ if (levelSwitch == null) throw new ArgumentNullException(nameof(levelSwitch));
_sink = sink;
- _restrictedMinimumLevel = restrictedMinimumLevel;
+ _levelSwitch = levelSwitch;
}
public void Emit(LogEvent logEvent)
{
- if (logEvent == null) throw new ArgumentNullException("logEvent");
+ if (logEvent == null) throw new ArgumentNullException(nameof(logEvent));
- if (logEvent.Level < _restrictedMinimumLevel)
+ if ((int)logEvent.Level < (int)_levelSwitch.MinimumLevel)
return;
_sink.Emit(logEvent);
diff --git a/src/Serilog/Core/Sinks/SafeAggregateSink.cs b/src/Serilog/Core/Sinks/SafeAggregateSink.cs
index e9f2d65d7..c406ee6b0 100644
--- a/src/Serilog/Core/Sinks/SafeAggregateSink.cs
+++ b/src/Serilog/Core/Sinks/SafeAggregateSink.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -25,7 +25,7 @@ class SafeAggregateSink : ILogEventSink
public SafeAggregateSink(IEnumerable sinks)
{
- if (sinks == null) throw new ArgumentNullException("sinks");
+ if (sinks == null) throw new ArgumentNullException(nameof(sinks));
_sinks = sinks;
}
diff --git a/src/Serilog/Core/Sinks/SecondaryLoggerSink.cs b/src/Serilog/Core/Sinks/SecondaryLoggerSink.cs
index 3239dd09a..d416f4560 100644
--- a/src/Serilog/Core/Sinks/SecondaryLoggerSink.cs
+++ b/src/Serilog/Core/Sinks/SecondaryLoggerSink.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -32,14 +32,14 @@ sealed class SecondaryLoggerSink : ILogEventSink, IDisposable
public SecondaryLoggerSink(ILogger logger, bool attemptDispose = false)
{
- if (logger == null) throw new ArgumentNullException("logger");
+ if (logger == null) throw new ArgumentNullException(nameof(logger));
_logger = logger;
_attemptDispose = attemptDispose;
}
public void Emit(LogEvent logEvent)
{
- if (logEvent == null) throw new ArgumentNullException("logEvent");
+ if (logEvent == null) throw new ArgumentNullException(nameof(logEvent));
var copy = new LogEvent(
logEvent.Timestamp,
diff --git a/src/Serilog/Debugging/LoggingFailedException.cs b/src/Serilog/Debugging/LoggingFailedException.cs
index 8bcfc6f10..bd47060d1 100644
--- a/src/Serilog/Debugging/LoggingFailedException.cs
+++ b/src/Serilog/Debugging/LoggingFailedException.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
diff --git a/src/Serilog/Debugging/SelfLog.cs b/src/Serilog/Debugging/SelfLog.cs
index 205c82437..c38959637 100644
--- a/src/Serilog/Debugging/SelfLog.cs
+++ b/src/Serilog/Debugging/SelfLog.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@ public static class SelfLog
///
/// SelfLog.Out = Console.Error;
///
+ // ReSharper disable once MemberCanBePrivate.Global, UnusedAutoPropertyAccessor.Global
public static TextWriter Out { get; set; }
///
diff --git a/src/Serilog.FullNetFx/Enrichers/EnvironmentUserNameEnricher.cs b/src/Serilog/Enrichers/EnvironmentUserNameEnricher.cs
similarity index 92%
rename from src/Serilog.FullNetFx/Enrichers/EnvironmentUserNameEnricher.cs
rename to src/Serilog/Enrichers/EnvironmentUserNameEnricher.cs
index 81ba56b0d..710cad5bd 100644
--- a/src/Serilog.FullNetFx/Enrichers/EnvironmentUserNameEnricher.cs
+++ b/src/Serilog/Enrichers/EnvironmentUserNameEnricher.cs
@@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+#if !PROFILE259
+
using System;
using Serilog.Core;
using Serilog.Events;
@@ -43,16 +45,16 @@ public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
private static string GetEnvironmentUserName()
{
-#if !ASPNETCORE50
+#if !DNXCORE50
var userDomainName = Environment.UserDomainName;
var userName = Environment.UserName;
#else
var userDomainName = Environment.GetEnvironmentVariable("USERNAME");
var userName = Environment.GetEnvironmentVariable("USERDOMAIN");
#endif
- return !string.IsNullOrWhiteSpace(userDomainName)
- ? string.Format(@"{0}\{1}", userDomainName, userName)
- : userName;
+ return !string.IsNullOrWhiteSpace(userDomainName) ? $@"{userDomainName}\{userName}" : userName;
}
}
}
+
+#endif
diff --git a/src/Serilog.FullNetFx/Enrichers/LogContextEnricher.cs b/src/Serilog/Enrichers/LogContextEnricher.cs
similarity index 92%
rename from src/Serilog.FullNetFx/Enrichers/LogContextEnricher.cs
rename to src/Serilog/Enrichers/LogContextEnricher.cs
index f464ace27..e6c21f680 100644
--- a/src/Serilog.FullNetFx/Enrichers/LogContextEnricher.cs
+++ b/src/Serilog/Enrichers/LogContextEnricher.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#if !ASPNETCORE50
+#if !PROFILE259 && !DNXCORE50
using Serilog.Context;
using Serilog.Core;
using Serilog.Events;
diff --git a/src/Serilog.FullNetFx/Enrichers/MachineNameEnricher.cs b/src/Serilog/Enrichers/MachineNameEnricher.cs
similarity index 95%
rename from src/Serilog.FullNetFx/Enrichers/MachineNameEnricher.cs
rename to src/Serilog/Enrichers/MachineNameEnricher.cs
index f6be9a7af..efc627285 100644
--- a/src/Serilog.FullNetFx/Enrichers/MachineNameEnricher.cs
+++ b/src/Serilog/Enrichers/MachineNameEnricher.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
using Serilog.Core;
using Serilog.Events;
+#if !PROFILE259
namespace Serilog.Enrichers
{
///
@@ -37,7 +38,7 @@ public class MachineNameEnricher : ILogEventEnricher
/// Factory for creating new properties to add to the event.
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
{
-#if !ASPNETCORE50
+#if !DNXCORE50
_cachedProperty = _cachedProperty ?? propertyFactory.CreateProperty(MachineNamePropertyName, Environment.MachineName);
#else
_cachedProperty = _cachedProperty ?? propertyFactory.CreateProperty(MachineNamePropertyName, Environment.GetEnvironmentVariable("COMPUTERNAME"));
@@ -46,3 +47,4 @@ public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
}
}
}
+#endif
diff --git a/src/Serilog.FullNetFx/Enrichers/ProcessIdEnricher.cs b/src/Serilog/Enrichers/ProcessIdEnricher.cs
similarity index 87%
rename from src/Serilog.FullNetFx/Enrichers/ProcessIdEnricher.cs
rename to src/Serilog/Enrichers/ProcessIdEnricher.cs
index 3a58d7947..6dbf681ca 100644
--- a/src/Serilog.FullNetFx/Enrichers/ProcessIdEnricher.cs
+++ b/src/Serilog/Enrichers/ProcessIdEnricher.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -12,14 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-using System.Diagnostics;
using Serilog.Core;
using Serilog.Events;
+#if !PROFILE259
namespace Serilog.Enrichers
{
///
- /// Enriches log events with a ProcessId property containing the current .
+ /// Enriches log events with a ProcessId property containing the current .
///
public class ProcessIdEnricher : ILogEventEnricher
{
@@ -37,8 +37,9 @@ public class ProcessIdEnricher : ILogEventEnricher
/// Factory for creating new properties to add to the event.
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
{
- _cachedProperty = _cachedProperty ?? propertyFactory.CreateProperty(ProcessIdPropertyName, Process.GetCurrentProcess().Id);
+ _cachedProperty = _cachedProperty ?? propertyFactory.CreateProperty(ProcessIdPropertyName, System.Diagnostics.Process.GetCurrentProcess().Id);
logEvent.AddPropertyIfAbsent(_cachedProperty);
}
}
}
+#endif
diff --git a/src/Serilog.FullNetFx/Enrichers/ThreadIdEnricher.cs b/src/Serilog/Enrichers/ThreadIdEnricher.cs
similarity index 95%
rename from src/Serilog.FullNetFx/Enrichers/ThreadIdEnricher.cs
rename to src/Serilog/Enrichers/ThreadIdEnricher.cs
index f2cb9cf3f..429c2df4d 100644
--- a/src/Serilog.FullNetFx/Enrichers/ThreadIdEnricher.cs
+++ b/src/Serilog/Enrichers/ThreadIdEnricher.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
using Serilog.Core;
using Serilog.Events;
+#if !PROFILE259
namespace Serilog.Enrichers
{
///
@@ -39,3 +40,4 @@ public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
}
}
}
+#endif
diff --git a/src/Serilog/Events/DictionaryValue-net40.cs b/src/Serilog/Events/DictionaryValue-net40.cs
deleted file mode 100644
index 39d718a03..000000000
--- a/src/Serilog/Events/DictionaryValue-net40.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright 2013 Serilog Contributors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-
-namespace Serilog.Events
-{
- ///
- /// A value represented as a mapping from keys to values.
- ///
- public class DictionaryValue : LogEventPropertyValue
- {
- readonly IDictionary _elements;
-
- ///
- /// Create a with the provided .
- ///
- /// The key-value mappings represented in the dictionary.
- ///
- public DictionaryValue(IEnumerable> elements)
- {
- if (elements == null) throw new ArgumentNullException("elements");
- _elements = elements.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
- }
-
- ///
- /// The dictionary mapping.
- ///
- public IDictionary Elements { get { return _elements; } }
-
- ///
- /// Render the value to the output.
- ///
- /// The output.
- /// A format string applied to the value, or null.
- /// A format provider to apply to the value, or null to use the default.
- /// .
- public override void Render(TextWriter output, string format = null, IFormatProvider formatProvider = null)
- {
- if (output == null) throw new ArgumentNullException("output");
-
- output.Write('[');
- var delim = "(";
- foreach (var kvp in _elements)
- {
- output.Write(delim);
- delim = ", (";
- kvp.Key.Render(output, null, formatProvider);
- output.Write(": ");
- kvp.Value.Render(output, null, formatProvider);
- output.Write(")");
- }
-
- output.Write(']');
- }
- }
-}
diff --git a/src/Serilog/Events/DictionaryValue.cs b/src/Serilog/Events/DictionaryValue.cs
index e1403bef0..5ca23fe4f 100644
--- a/src/Serilog/Events/DictionaryValue.cs
+++ b/src/Serilog/Events/DictionaryValue.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -17,6 +17,12 @@
using System.IO;
using System.Linq;
+#if NET40
+using IScalarDictionary = System.Collections.Generic.IDictionary;
+#else
+using IScalarDictionary = System.Collections.Generic.IReadOnlyDictionary;
+#endif
+
namespace Serilog.Events
{
///
@@ -24,7 +30,7 @@ namespace Serilog.Events
///
public class DictionaryValue : LogEventPropertyValue
{
- readonly IReadOnlyDictionary _elements;
+ readonly IScalarDictionary _elements;
///
/// Create a with the provided .
@@ -33,14 +39,14 @@ public class DictionaryValue : LogEventPropertyValue
///
public DictionaryValue(IEnumerable> elements)
{
- if (elements == null) throw new ArgumentNullException("elements");
+ if (elements == null) throw new ArgumentNullException(nameof(elements));
_elements = elements.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
}
///
/// The dictionary mapping.
///
- public IReadOnlyDictionary Elements { get { return _elements; } }
+ public IScalarDictionary Elements { get { return _elements; } }
///
/// Render the value to the output.
@@ -51,7 +57,7 @@ public DictionaryValue(IEnumerable.
public override void Render(TextWriter output, string format = null, IFormatProvider formatProvider = null)
{
- if (output == null) throw new ArgumentNullException("output");
+ if (output == null) throw new ArgumentNullException(nameof(output));
output.Write('[');
var delim = "(";
diff --git a/src/Serilog/Events/LevelAlias.cs b/src/Serilog/Events/LevelAlias.cs
index cbf291be3..d850654c1 100644
--- a/src/Serilog/Events/LevelAlias.cs
+++ b/src/Serilog/Events/LevelAlias.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
diff --git a/src/Serilog/Events/LogEvent-net40.cs b/src/Serilog/Events/LogEvent-net40.cs
deleted file mode 100644
index 4bb155ba1..000000000
--- a/src/Serilog/Events/LogEvent-net40.cs
+++ /dev/null
@@ -1,147 +0,0 @@
-// Copyright 2013 Serilog Contributors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-
-namespace Serilog.Events
-{
- ///
- /// A log event.
- ///
- public class LogEvent
- {
- readonly DateTimeOffset _timestamp;
- readonly LogEventLevel _level;
- readonly Exception _exception;
- readonly MessageTemplate _messageTemplate;
- readonly Dictionary _properties;
-
- ///
- /// Construct a new .
- ///
- /// The time at which the event occurred.
- /// The level of the event.
- /// An exception associated with the event, or null.
- /// The message template describing the event.
- /// Properties associated with the event, including those presented in .
- public LogEvent(DateTimeOffset timestamp, LogEventLevel level, Exception exception, MessageTemplate messageTemplate, IEnumerable properties)
- {
- if (messageTemplate == null) throw new ArgumentNullException("messageTemplate");
- if (properties == null) throw new ArgumentNullException("properties");
- _timestamp = timestamp;
- _level = level;
- _exception = exception;
- _messageTemplate = messageTemplate;
- _properties = new Dictionary();
- foreach (var p in properties)
- AddOrUpdateProperty(p);
- }
-
- ///
- /// The time at which the event occurred.
- ///
- public DateTimeOffset Timestamp
- {
- get { return _timestamp; }
- }
-
- ///
- /// The level of the event.
- ///
- public LogEventLevel Level
- {
- get { return _level; }
- }
-
- ///
- /// The message template describing the event.
- ///
- public MessageTemplate MessageTemplate
- {
- get { return _messageTemplate; }
- }
-
- ///
- /// Render the message template to the specified output, given the properties associated
- /// with the event.
- ///
- /// The output.
- /// Supplies culture-specific formatting information, or null.
- public void RenderMessage(TextWriter output, IFormatProvider formatProvider = null)
- {
- MessageTemplate.Render(Properties, output, formatProvider);
- }
-
- ///
- /// Render the message template given the properties associated
- /// with the event, and return the result.
- ///
- /// Supplies culture-specific formatting information, or null.
- public string RenderMessage(IFormatProvider formatProvider = null)
- {
- return MessageTemplate.Render(Properties, formatProvider);
- }
-
- ///
- /// Properties associated with the event, including those presented in .
- ///
- public IDictionary Properties
- {
- get { return _properties; }
- }
-
- ///
- /// An exception associated with the event, or null.
- ///
- public Exception Exception
- {
- get { return _exception; }
- }
-
- ///
- /// Add a property to the event if not already present, otherwise, update its value.
- ///
- /// The property to add or update.
- ///
- public void AddOrUpdateProperty(LogEventProperty property)
- {
- if (property == null) throw new ArgumentNullException("property");
- _properties[property.Name] = property.Value;
- }
-
- ///
- /// Add a property to the event if not already present.
- ///
- /// The property to add.
- ///
- public void AddPropertyIfAbsent(LogEventProperty property)
- {
- if (property == null) throw new ArgumentNullException("property");
- if (!_properties.ContainsKey(property.Name))
- _properties.Add(property.Name, property.Value);
- }
-
- ///
- /// Remove a property from the event, if present. Otherwise no action
- /// is performed.
- ///
- /// The name of the property to remove.
- public void RemovePropertyIfPresent(string propertyName)
- {
- _properties.Remove(propertyName);
- }
- }
-}
\ No newline at end of file
diff --git a/src/Serilog/Events/LogEvent.cs b/src/Serilog/Events/LogEvent.cs
index d2e87d21e..7eccff9cd 100644
--- a/src/Serilog/Events/LogEvent.cs
+++ b/src/Serilog/Events/LogEvent.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -16,6 +16,12 @@
using System.Collections.Generic;
using System.IO;
+#if NET40
+using IPropertyDictionary = System.Collections.Generic.IDictionary;
+#else
+using IPropertyDictionary = System.Collections.Generic.IReadOnlyDictionary;
+#endif
+
namespace Serilog.Events
{
///
@@ -39,8 +45,8 @@ public class LogEvent
/// Properties associated with the event, including those presented in .
public LogEvent(DateTimeOffset timestamp, LogEventLevel level, Exception exception, MessageTemplate messageTemplate, IEnumerable properties)
{
- if (messageTemplate == null) throw new ArgumentNullException("messageTemplate");
- if (properties == null) throw new ArgumentNullException("properties");
+ if (messageTemplate == null) throw new ArgumentNullException(nameof(messageTemplate));
+ if (properties == null) throw new ArgumentNullException(nameof(properties));
_timestamp = timestamp;
_level = level;
_exception = exception;
@@ -98,7 +104,7 @@ public string RenderMessage(IFormatProvider formatProvider = null)
///
/// Properties associated with the event, including those presented in .
///
- public IReadOnlyDictionary Properties
+ public IPropertyDictionary Properties
{
get { return _properties; }
}
@@ -118,7 +124,7 @@ public Exception Exception
///
public void AddOrUpdateProperty(LogEventProperty property)
{
- if (property == null) throw new ArgumentNullException("property");
+ if (property == null) throw new ArgumentNullException(nameof(property));
_properties[property.Name] = property.Value;
}
@@ -129,7 +135,7 @@ public void AddOrUpdateProperty(LogEventProperty property)
///
public void AddPropertyIfAbsent(LogEventProperty property)
{
- if (property == null) throw new ArgumentNullException("property");
+ if (property == null) throw new ArgumentNullException(nameof(property));
if (!_properties.ContainsKey(property.Name))
_properties.Add(property.Name, property.Value);
}
diff --git a/src/Serilog/Events/LogEventLevel.cs b/src/Serilog/Events/LogEventLevel.cs
index 9642abdfb..9ab996748 100644
--- a/src/Serilog/Events/LogEventLevel.cs
+++ b/src/Serilog/Events/LogEventLevel.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
diff --git a/src/Serilog/Events/LogEventProperty.cs b/src/Serilog/Events/LogEventProperty.cs
index d8f3e9046..46fe2fca2 100644
--- a/src/Serilog/Events/LogEventProperty.cs
+++ b/src/Serilog/Events/LogEventProperty.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -33,7 +33,7 @@ public class LogEventProperty
///
public LogEventProperty(string name, LogEventPropertyValue value)
{
- if (value == null) throw new ArgumentNullException("value");
+ if (value == null) throw new ArgumentNullException(nameof(value));
if (!IsValidName(name))
throw new ArgumentException("Property name is not valid.");
diff --git a/src/Serilog/Events/LogEventPropertyValue.cs b/src/Serilog/Events/LogEventPropertyValue.cs
index 8979b004e..0063242bd 100644
--- a/src/Serilog/Events/LogEventPropertyValue.cs
+++ b/src/Serilog/Events/LogEventPropertyValue.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
diff --git a/src/Serilog/Events/MessageTemplate-net40.cs b/src/Serilog/Events/MessageTemplate-net40.cs
deleted file mode 100644
index bd44f190b..000000000
--- a/src/Serilog/Events/MessageTemplate-net40.cs
+++ /dev/null
@@ -1,157 +0,0 @@
-// Copyright 2013 Serilog Contributors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using Serilog.Debugging;
-using Serilog.Parsing;
-
-namespace Serilog.Events
-{
- ///
- /// Represents a message template passed to a log method. The template
- /// can subsequently render the template in textual form given the list
- /// of properties.
- ///
- public class MessageTemplate
- {
- readonly string _text;
- readonly MessageTemplateToken[] _tokens;
-
- // Optimisation for when the template is bound to
- // property values.
- readonly PropertyToken[] _positionalProperties;
- readonly PropertyToken[] _namedProperties;
-
- ///
- /// Construct a message template using manually-defined text and property tokens.
- ///
- /// The text and property tokens defining the template.
- public MessageTemplate(IEnumerable tokens)
- : this(string.Join("", tokens), tokens)
- {
- }
-
- ///
- /// Construct a message template using manually-defined text and property tokens.
- ///
- /// The full text of the template; used by Serilog internally to avoid unneeded
- /// string concatenation.
- /// The text and property tokens defining the template.
- public MessageTemplate(string text, IEnumerable tokens)
- {
- if (text == null) throw new ArgumentNullException("text");
- if (tokens == null) throw new ArgumentNullException("tokens");
-
- _text = text;
- _tokens = tokens.ToArray();
-
- var propertyTokens = _tokens.OfType().ToArray();
- if (propertyTokens.Length != 0)
- {
- var allPositional = true;
- var anyPositional = false;
- foreach (var propertyToken in propertyTokens)
- {
- if (propertyToken.IsPositional)
- anyPositional = true;
- else
- allPositional = false;
- }
-
- if (allPositional)
- {
- _positionalProperties = propertyTokens;
- }
- else
- {
- if (anyPositional)
- SelfLog.WriteLine("Message template is malformed: {0}", text);
-
- _namedProperties = propertyTokens;
- }
- }
- }
-
- ///
- /// The raw text describing the template.
- ///
- public string Text
- {
- get { return _text; }
- }
-
- ///
- /// Render the template as a string.
- ///
- /// The string representation of the template.
- public override string ToString()
- {
- return Text;
- }
-
- ///
- /// The tokens parsed from the template.
- ///
- public IEnumerable Tokens
- {
- get { return _tokens; }
- }
-
- internal PropertyToken[] NamedProperties
- {
- get { return _namedProperties; }
- }
-
- internal PropertyToken[] PositionalProperties
- {
- get { return _positionalProperties; }
- }
-
- ///
- /// Convert the message template into a textual message, given the
- /// properties matching the tokens in the message template.
- ///
- /// Properties matching template tokens.
- /// Supplies culture-specific formatting information, or null.
- /// The message created from the template and properties. If the
- /// properties are mismatched with the template, the template will be
- /// returned with incomplete substitution.
- public string Render(IDictionary properties, IFormatProvider formatProvider = null)
- {
- var writer = new StringWriter(formatProvider);
- Render(properties, writer, formatProvider);
- return writer.ToString();
- }
-
- ///
- /// Convert the message template into a textual message, given the
- /// properties matching the tokens in the message template.
- ///
- /// Properties matching template tokens.
- /// The message created from the template and properties. If the
- /// properties are mismatched with the template, the template will be
- /// returned with incomplete substitution.
- /// Supplies culture-specific formatting information, or null.
- public void Render(IDictionary properties, TextWriter output, IFormatProvider formatProvider = null)
- {
- foreach (var token in _tokens)
- {
- token.Render(properties, output, formatProvider);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/Serilog/Events/MessageTemplate.cs b/src/Serilog/Events/MessageTemplate.cs
index f09f3aa23..d1d0f5f79 100644
--- a/src/Serilog/Events/MessageTemplate.cs
+++ b/src/Serilog/Events/MessageTemplate.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -19,6 +19,12 @@
using Serilog.Debugging;
using Serilog.Parsing;
+#if NET40
+using IPropertyDictionary = System.Collections.Generic.IDictionary;
+#else
+using IPropertyDictionary = System.Collections.Generic.IReadOnlyDictionary;
+#endif
+
namespace Serilog.Events
{
///
@@ -53,8 +59,8 @@ public MessageTemplate(IEnumerable tokens)
/// The text and property tokens defining the template.
public MessageTemplate(string text, IEnumerable tokens)
{
- if (text == null) throw new ArgumentNullException("text");
- if (tokens == null) throw new ArgumentNullException("tokens");
+ if (text == null) throw new ArgumentNullException(nameof(text));
+ if (tokens == null) throw new ArgumentNullException(nameof(tokens));
_text = text;
_tokens = tokens.ToArray();
@@ -130,7 +136,7 @@ internal PropertyToken[] PositionalProperties
/// The message created from the template and properties. If the
/// properties are mismatched with the template, the template will be
/// returned with incomplete substitution.
- public string Render(IReadOnlyDictionary properties, IFormatProvider formatProvider = null)
+ public string Render(IPropertyDictionary properties, IFormatProvider formatProvider = null)
{
var writer = new StringWriter(formatProvider);
Render(properties, writer, formatProvider);
@@ -146,7 +152,7 @@ public string Render(IReadOnlyDictionary properti
/// properties are mismatched with the template, the template will be
/// returned with incomplete substitution.
/// Supplies culture-specific formatting information, or null.
- public void Render(IReadOnlyDictionary properties, TextWriter output, IFormatProvider formatProvider = null)
+ public void Render(IPropertyDictionary properties, TextWriter output, IFormatProvider formatProvider = null)
{
foreach (var token in _tokens)
{
diff --git a/src/Serilog/Events/ScalarValue.cs b/src/Serilog/Events/ScalarValue.cs
index 106d0b044..c6c66cbee 100644
--- a/src/Serilog/Events/ScalarValue.cs
+++ b/src/Serilog/Events/ScalarValue.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -49,7 +49,7 @@ public ScalarValue(object value)
/// .
public override void Render(TextWriter output, string format = null, IFormatProvider formatProvider = null)
{
- if (output == null) throw new ArgumentNullException("output");
+ if (output == null) throw new ArgumentNullException(nameof(output));
if (_value == null)
{
diff --git a/src/Serilog/Events/SequenceValue-net40.cs b/src/Serilog/Events/SequenceValue-net40.cs
deleted file mode 100644
index 5d509f18b..000000000
--- a/src/Serilog/Events/SequenceValue-net40.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright 2013 Serilog Contributors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-
-namespace Serilog.Events
-{
- ///
- /// A value represented as an ordered sequence of values.
- ///
- public class SequenceValue : LogEventPropertyValue
- {
- readonly LogEventPropertyValue[] _elements;
-
- ///
- /// Create a with the provided .
- ///
- /// The elements of the sequence.
- ///
- public SequenceValue(IEnumerable elements)
- {
- if (elements == null) throw new ArgumentNullException("elements");
- _elements = elements.ToArray();
- }
-
- ///
- /// The elements of the sequence.
- ///
- public IList Elements { get { return _elements; } }
-
- ///
- /// Render the value to the output.
- ///
- /// The output.
- /// A format string applied to the value, or null.
- /// A format provider to apply to the value, or null to use the default.
- /// .
- public override void Render(TextWriter output, string format = null, IFormatProvider formatProvider = null)
- {
- if (output == null) throw new ArgumentNullException("output");
-
- output.Write('[');
- var allButLast = _elements.Length - 1;
- for (var i = 0; i < allButLast; ++i )
- {
- _elements[i].Render(output, format, formatProvider);
- output.Write(", ");
- }
-
- if (_elements.Length > 0)
- _elements[_elements.Length - 1].Render(output, format, formatProvider);
-
- output.Write(']');
- }
- }
-}
\ No newline at end of file
diff --git a/src/Serilog/Events/SequenceValue.cs b/src/Serilog/Events/SequenceValue.cs
index bdc540df8..895f04861 100644
--- a/src/Serilog/Events/SequenceValue.cs
+++ b/src/Serilog/Events/SequenceValue.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -17,6 +17,12 @@
using System.IO;
using System.Linq;
+#if NET40
+using IPropertyValueList = System.Collections.Generic.IList;
+#else
+using IPropertyValueList = System.Collections.Generic.IReadOnlyList;
+#endif
+
namespace Serilog.Events
{
///
@@ -33,14 +39,14 @@ public class SequenceValue : LogEventPropertyValue
///
public SequenceValue(IEnumerable elements)
{
- if (elements == null) throw new ArgumentNullException("elements");
+ if (elements == null) throw new ArgumentNullException(nameof(elements));
_elements = elements.ToArray();
}
///
/// The elements of the sequence.
///
- public IReadOnlyList Elements { get { return _elements; } }
+ public IPropertyValueList Elements { get { return _elements; } }
///
/// Render the value to the output.
@@ -51,7 +57,7 @@ public SequenceValue(IEnumerable elements)
/// .
public override void Render(TextWriter output, string format = null, IFormatProvider formatProvider = null)
{
- if (output == null) throw new ArgumentNullException("output");
+ if (output == null) throw new ArgumentNullException(nameof(output));
output.Write('[');
var allButLast = _elements.Length - 1;
diff --git a/src/Serilog/Events/StructureValue-net40.cs b/src/Serilog/Events/StructureValue-net40.cs
deleted file mode 100644
index 33530becc..000000000
--- a/src/Serilog/Events/StructureValue-net40.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-using System;
-using System.Collections.Generic;
-// Copyright 2013 Serilog Contributors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-using System.IO;
-using System.Linq;
-
-namespace Serilog.Events
-{
- ///
- /// A value represented as a collection of name-value properties.
- ///
- public class StructureValue : LogEventPropertyValue
- {
- readonly string _typeTag;
- readonly LogEventProperty[] _properties;
-
- ///
- /// Construct a with the provided properties.
- ///
- /// Optionally, a piece of metadata describing the "type" of the
- /// structure.
- /// The properties of the structure.
- ///
- public StructureValue(IEnumerable properties, string typeTag = null)
- {
- if (properties == null) throw new ArgumentNullException("properties");
- _typeTag = typeTag;
- _properties = properties.ToArray();
- }
-
- ///
- /// A piece of metadata describing the "type" of the
- /// structure, or null.
- ///
- public string TypeTag { get { return _typeTag; } }
-
- ///
- /// The properties of the structure.
- ///
- /// Not presented as a dictionary because dictionary construction is
- /// relatively expensive; it is cheaper to build a dictionary over properties only
- /// when the structure is of interest.
- public IList Properties { get { return _properties; } }
-
- ///
- /// Render the value to the output.
- ///
- /// The output.
- /// A format string applied to the value, or null.
- /// A format provider to apply to the value, or null to use the default.
- /// .
- public override void Render(TextWriter output, string format = null, IFormatProvider formatProvider = null)
- {
- if (output == null) throw new ArgumentNullException("output");
-
- if (_typeTag != null)
- {
- output.Write(_typeTag);
- output.Write(' ');
- }
- output.Write("{ ");
- var allButLast = _properties.Length - 1;
- for (var i = 0; i < allButLast; i++)
- {
- var property = _properties[i];
- Render(output, property, formatProvider);
- output.Write(", ");
- }
-
- if (_properties.Length > 0)
- {
- var last = _properties[_properties.Length - 1];
- Render(output, last, formatProvider);
- }
-
- output.Write(" }");
- }
-
- static void Render(TextWriter output, LogEventProperty property, IFormatProvider formatProvider = null)
- {
- output.Write(property.Name);
- output.Write(": ");
- property.Value.Render(output, null, formatProvider);
- }
- }
-}
\ No newline at end of file
diff --git a/src/Serilog/Events/StructureValue.cs b/src/Serilog/Events/StructureValue.cs
index 3af1b5119..3c21bcdfb 100644
--- a/src/Serilog/Events/StructureValue.cs
+++ b/src/Serilog/Events/StructureValue.cs
@@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -17,6 +17,12 @@
using System.IO;
using System.Linq;
+#if NET40
+using IPropertyList = System.Collections.Generic.IList;
+#else
+using IPropertyList = System.Collections.Generic.IReadOnlyList;
+#endif
+
namespace Serilog.Events
{
///
@@ -36,7 +42,7 @@ public class StructureValue : LogEventPropertyValue
///
public StructureValue(IEnumerable properties, string typeTag = null)
{
- if (properties == null) throw new ArgumentNullException("properties");
+ if (properties == null) throw new ArgumentNullException(nameof(properties));
_typeTag = typeTag;
_properties = properties.ToArray();
}
@@ -53,7 +59,7 @@ public StructureValue(IEnumerable properties, string typeTag =
/// Not presented as a dictionary because dictionary construction is
/// relatively expensive; it is cheaper to build a dictionary over properties only
/// when the structure is of interest.
- public IReadOnlyList Properties { get { return _properties; } }
+ public IPropertyList Properties { get { return _properties; } }
///
/// Render the value to the output.
@@ -64,7 +70,7 @@ public StructureValue(IEnumerable properties, string typeTag =
/// .
public override void Render(TextWriter output, string format = null, IFormatProvider formatProvider = null)
{
- if (output == null) throw new ArgumentNullException("output");
+ if (output == null) throw new ArgumentNullException(nameof(output));
if (_typeTag != null)
{
diff --git a/src/Serilog/Filters/Matching.cs b/src/Serilog/Filters/Matching.cs
index ee85655fa..e8e5bf998 100644
--- a/src/Serilog/Filters/Matching.cs
+++ b/src/Serilog/Filters/Matching.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -41,7 +41,7 @@ public static Func FromSource()
/// A function that matches log events emitted by the source.
public static Func FromSource(string source)
{
- if (source == null) throw new ArgumentNullException("source");
+ if (source == null) throw new ArgumentNullException(nameof(source));
var sourcePrefix = source + ".";
return WithProperty(Constants.SourceContextPropertyName, s => s != null && (s == source || s.StartsWith(sourcePrefix)));
}
@@ -54,7 +54,7 @@ public static Func FromSource(string source)
/// A predicate for matching events.
public static Func WithProperty(string propertyName)
{
- if (propertyName == null) throw new ArgumentNullException("propertyName");
+ if (propertyName == null) throw new ArgumentNullException(nameof(propertyName));
return e => e.Properties.ContainsKey(propertyName);
}
@@ -67,7 +67,7 @@ public static Func WithProperty(string propertyName)
/// A predicate for matching events.
public static Func WithProperty(string propertyName, object scalarValue)
{
- if (propertyName == null) throw new ArgumentNullException("propertyName");
+ if (propertyName == null) throw new ArgumentNullException(nameof(propertyName));
var scalar = new ScalarValue(scalarValue);
return e =>
{
@@ -86,8 +86,8 @@ public static Func WithProperty(string propertyName, object scal
/// A predicate for matching events.
public static Func WithProperty(string propertyName, Func predicate)
{
- if (propertyName == null) throw new ArgumentNullException("propertyName");
- if (predicate == null) throw new ArgumentNullException("predicate");
+ if (propertyName == null) throw new ArgumentNullException(nameof(propertyName));
+ if (predicate == null) throw new ArgumentNullException(nameof(predicate));
return e =>
{
diff --git a/src/Serilog/Formatting/Display/LiteralStringValue.cs b/src/Serilog/Formatting/Display/LiteralStringValue.cs
index 8c3aacc49..20748dc3a 100644
--- a/src/Serilog/Formatting/Display/LiteralStringValue.cs
+++ b/src/Serilog/Formatting/Display/LiteralStringValue.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@ class LiteralStringValue : LogEventPropertyValue
public LiteralStringValue(string value)
{
- if (value == null) throw new ArgumentNullException("value");
+ if (value == null) throw new ArgumentNullException(nameof(value));
_value = value;
}
diff --git a/src/Serilog/Formatting/Display/LogEventPropertyMessageValue-net40.cs b/src/Serilog/Formatting/Display/LogEventPropertyMessageValue-net40.cs
deleted file mode 100644
index 4498b94bf..000000000
--- a/src/Serilog/Formatting/Display/LogEventPropertyMessageValue-net40.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2013 Serilog Contributors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using Serilog.Events;
-
-namespace Serilog.Formatting.Display
-{
- class LogEventPropertyMessageValue : LogEventPropertyValue
- {
- readonly MessageTemplate _template;
- readonly IDictionary _properties;
-
- public LogEventPropertyMessageValue(MessageTemplate template, IDictionary properties)
- {
- _template = template;
- _properties = properties;
- }
-
- public override void Render(TextWriter output, string format = null, IFormatProvider formatProvider = null)
- {
- _template.Render(_properties, output, formatProvider);
- }
- }
-}
diff --git a/src/Serilog/Formatting/Display/LogEventPropertyMessageValue.cs b/src/Serilog/Formatting/Display/LogEventPropertyMessageValue.cs
index 791561c63..34bd1a0ac 100644
--- a/src/Serilog/Formatting/Display/LogEventPropertyMessageValue.cs
+++ b/src/Serilog/Formatting/Display/LogEventPropertyMessageValue.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -13,18 +13,23 @@
// limitations under the License.
using System;
-using System.Collections.Generic;
using System.IO;
using Serilog.Events;
+#if NET40
+using IPropertyDictionary = System.Collections.Generic.IDictionary;
+#else
+using IPropertyDictionary = System.Collections.Generic.IReadOnlyDictionary;
+#endif
+
namespace Serilog.Formatting.Display
{
class LogEventPropertyMessageValue : LogEventPropertyValue
{
readonly MessageTemplate _template;
- readonly IReadOnlyDictionary _properties;
+ readonly IPropertyDictionary _properties;
- public LogEventPropertyMessageValue(MessageTemplate template, IReadOnlyDictionary properties)
+ public LogEventPropertyMessageValue(MessageTemplate template, IPropertyDictionary properties)
{
_template = template;
_properties = properties;
diff --git a/src/Serilog/Formatting/Display/MessageTemplateTextFormatter.cs b/src/Serilog/Formatting/Display/MessageTemplateTextFormatter.cs
index 6810b108a..43edb0275 100644
--- a/src/Serilog/Formatting/Display/MessageTemplateTextFormatter.cs
+++ b/src/Serilog/Formatting/Display/MessageTemplateTextFormatter.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -43,7 +43,7 @@ public class MessageTemplateTextFormatter : ITextFormatter
/// Supplies culture-specific formatting information, or null.
public MessageTemplateTextFormatter(string outputTemplate, IFormatProvider formatProvider)
{
- if (outputTemplate == null) throw new ArgumentNullException("outputTemplate");
+ if (outputTemplate == null) throw new ArgumentNullException(nameof(outputTemplate));
_outputTemplate = new MessageTemplateParser().Parse(outputTemplate);
_formatProvider = formatProvider;
}
@@ -55,8 +55,8 @@ public MessageTemplateTextFormatter(string outputTemplate, IFormatProvider forma
/// The output.
public void Format(LogEvent logEvent, TextWriter output)
{
- if (logEvent == null) throw new ArgumentNullException("logEvent");
- if (output == null) throw new ArgumentNullException("output");
+ if (logEvent == null) throw new ArgumentNullException(nameof(logEvent));
+ if (output == null) throw new ArgumentNullException(nameof(output));
// This could be lazier: the output properties include
// everything from the log event, but often we won't need any more than
diff --git a/src/Serilog/Formatting/Display/OutputProperties-net40.cs b/src/Serilog/Formatting/Display/OutputProperties-net40.cs
deleted file mode 100644
index 36e7a5588..000000000
--- a/src/Serilog/Formatting/Display/OutputProperties-net40.cs
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright 2013 Serilog Contributors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Serilog.Events;
-
-namespace Serilog.Formatting.Display
-{
- ///
- /// Describes the properties available in standard message template-based
- /// output format strings.
- ///
- public static class OutputProperties
- {
- ///
- /// The message rendered from the log event.
- ///
- public const string MessagePropertyName = "Message";
-
- ///
- /// The timestamp of the log event.
- ///
- public const string TimestampPropertyName = "Timestamp";
-
- ///
- /// The level of the log event.
- ///
- public const string LevelPropertyName = "Level";
-
- ///
- /// A new line.
- ///
- public const string NewLinePropertyName = "NewLine";
-
- ///
- /// The exception associated with the log event.
- ///
- public const string ExceptionPropertyName = "Exception";
-
- ///
- /// Create properties from the provided log event.
- ///
- /// The log event.
- /// A dictionary with properties representing the log event.
- public static IDictionary GetOutputProperties(LogEvent logEvent)
- {
- var result = logEvent.Properties.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
-
- // "Special" output properties like Message will override any properties with the same name
- // when used in format strings; this doesn't affect the rendering of the message template,
- // which uses only the log event properties.
-
- result[MessagePropertyName] = new LogEventPropertyMessageValue(logEvent.MessageTemplate, logEvent.Properties);
- result[TimestampPropertyName] = new ScalarValue(logEvent.Timestamp);
- result[LevelPropertyName] = new ScalarValue(logEvent.Level);
- result[NewLinePropertyName] = new LiteralStringValue(Environment.NewLine);
-
- var exception = logEvent.Exception == null ? "" : (logEvent.Exception + Environment.NewLine);
- result[ExceptionPropertyName] = new LiteralStringValue(exception);
-
- return result;
- }
- }
-}
diff --git a/src/Serilog/Formatting/Display/OutputProperties.cs b/src/Serilog/Formatting/Display/OutputProperties.cs
index 62ad6f987..f32b3e534 100644
--- a/src/Serilog/Formatting/Display/OutputProperties.cs
+++ b/src/Serilog/Formatting/Display/OutputProperties.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -13,10 +13,15 @@
// limitations under the License.
using System;
-using System.Collections.Generic;
using System.Linq;
using Serilog.Events;
+#if NET40
+using IPropertyDictionary = System.Collections.Generic.IDictionary;
+#else
+using IPropertyDictionary = System.Collections.Generic.IReadOnlyDictionary;
+#endif
+
namespace Serilog.Formatting.Display
{
///
@@ -55,7 +60,7 @@ public static class OutputProperties
///
/// The log event.
/// A dictionary with properties representing the log event.
- public static IReadOnlyDictionary GetOutputProperties(LogEvent logEvent)
+ public static IPropertyDictionary GetOutputProperties(LogEvent logEvent)
{
var result = logEvent.Properties.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
diff --git a/src/Serilog/Formatting/ITextFormatter.cs b/src/Serilog/Formatting/ITextFormatter.cs
index 4b7470a0c..82e4f7264 100644
--- a/src/Serilog/Formatting/ITextFormatter.cs
+++ b/src/Serilog/Formatting/ITextFormatter.cs
@@ -1,4 +1,4 @@
-// Copyright 2014 Serilog Contributors
+// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
diff --git a/src/Serilog/Formatting/Json/JsonFormatter-net40.cs b/src/Serilog/Formatting/Json/JsonFormatter-net40.cs
deleted file mode 100644
index 1c9ee7ef0..000000000
--- a/src/Serilog/Formatting/Json/JsonFormatter-net40.cs
+++ /dev/null
@@ -1,476 +0,0 @@
-// Copyright 2014 Serilog Contributors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Globalization;
-using System.IO;
-using System.Linq;
-using System.Text;
-using Serilog.Events;
-using Serilog.Parsing;
-
-namespace Serilog.Formatting.Json
-{
- ///
- /// Formats log events in a simple JSON structure. Instances of this class
- /// are safe for concurrent access by multiple threads.
- ///
- public class JsonFormatter : ITextFormatter
- {
- readonly bool _omitEnclosingObject;
- readonly string _closingDelimiter;
- readonly bool _renderMessage;
- readonly IFormatProvider _formatProvider;
- readonly IDictionary> _literalWriters;
-
- ///
- /// Construct a . Obsolete, please use named arguments
- /// when calling this constructor.
- ///
- [Obsolete("Use named arguments with this method to guarantee forwards-compatibility."), EditorBrowsable(EditorBrowsableState.Never)]
- public JsonFormatter(bool omitEnclosingObjectObsolete)
- : this(omitEnclosingObject: omitEnclosingObjectObsolete)
- {
- }
-
- ///
- /// Construct a .
- ///
- /// If true, the properties of the event will be written to
- /// the output without enclosing braces. Otherwise, if false, each event will be written as a well-formed
- /// JSON object.
- /// A string that will be written after each log event is formatted.
- /// If null, will be used. Ignored if
- /// is true.
- /// If true, the message will be rendered and written to the output as a
- /// property named RenderedMessage.
- /// Supplies culture-specific formatting information, or null.
- public JsonFormatter(
- bool omitEnclosingObject = false,
- string closingDelimiter = null,
- bool renderMessage = false,
- IFormatProvider formatProvider = null)
- {
- _omitEnclosingObject = omitEnclosingObject;
- _closingDelimiter = closingDelimiter ?? Environment.NewLine;
- _renderMessage = renderMessage;
- _formatProvider = formatProvider;
-
- _literalWriters = new Dictionary>
- {
- { typeof(bool), (v, q, w) => WriteBoolean((bool)v, w) },
- { typeof(char), (v, q, w) => WriteString(((char)v).ToString(), w) },
- { typeof(byte), WriteToString },
- { typeof(sbyte), WriteToString },
- { typeof(short), WriteToString },
- { typeof(ushort), WriteToString },
- { typeof(int), WriteToString },
- { typeof(uint), WriteToString },
- { typeof(long), WriteToString },
- { typeof(ulong), WriteToString },
- { typeof(float), WriteToString },
- { typeof(double), WriteToString },
- { typeof(decimal), WriteToString },
- { typeof(string), (v, q, w) => WriteString((string)v, w) },
- { typeof(DateTime), (v, q, w) => WriteDateTime((DateTime)v, w) },
- { typeof(DateTimeOffset), (v, q, w) => WriteOffset((DateTimeOffset)v, w) },
- { typeof(ScalarValue), (v, q, w) => WriteLiteral(((ScalarValue)v).Value, w, q) },
- { typeof(SequenceValue), (v, q, w) => WriteSequence(((SequenceValue)v).Elements, w) },
- { typeof(DictionaryValue), (v, q, w) => WriteDictionary(((DictionaryValue)v).Elements, w) },
- { typeof(StructureValue), (v, q, w) => WriteStructure(((StructureValue)v).TypeTag, ((StructureValue)v).Properties, w) },
- };
- }
-
- ///
- /// Format the log event into the output.
- ///
- /// The event to format.
- /// The output.
- public void Format(LogEvent logEvent, TextWriter output)
- {
- if (logEvent == null) throw new ArgumentNullException("logEvent");
- if (output == null) throw new ArgumentNullException("output");
-
- if (!_omitEnclosingObject)
- output.Write("{");
-
- var delim = "";
- WriteTimestamp(logEvent.Timestamp, ref delim, output);
- WriteLevel(logEvent.Level, ref delim, output);
- WriteMessageTemplate(logEvent.MessageTemplate.Text, ref delim, output);
- if (_renderMessage)
- {
- var message = logEvent.RenderMessage(_formatProvider);
- WriteRenderedMessage(message, ref delim, output);
- }
-
- if (logEvent.Exception != null)
- WriteException(logEvent.Exception, ref delim, output);
-
- if (logEvent.Properties.Count != 0)
- WriteProperties(logEvent.Properties, output);
-
- var tokensWithFormat = logEvent.MessageTemplate.Tokens
- .OfType()
- .Where(pt => pt.Format != null)
- .GroupBy(pt => pt.PropertyName)
- .ToArray();
-
- if (tokensWithFormat.Length != 0)
- {
- WriteRenderings(tokensWithFormat, logEvent.Properties, output);
-
-
- }
-
- if (!_omitEnclosingObject)
- {
- output.Write("}");
- output.Write(_closingDelimiter);
- }
- }
-
- ///
- /// Adds a writer function for a given type.
- ///
- /// The type of values, which handles.
- /// The function, which writes the values.
- protected void AddLiteralWriter(Type type, Action