Skip to content

Commit 0fdfd0a

Browse files
committed
Include the actual files, this time
1 parent f50a62a commit 0fdfd0a

File tree

16 files changed

+414
-0
lines changed

16 files changed

+414
-0
lines changed

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Auto detect text files and perform LF normalization
2+
3+
* text=auto

Build.ps1

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Push-Location $PSScriptRoot
2+
3+
if(Test-Path .\artifacts) { Remove-Item .\artifacts -Force -Recurse }
4+
5+
& dotnet restore
6+
7+
$revision = @{ $true = $env:APPVEYOR_BUILD_NUMBER; $false = 1 }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
8+
9+
Push-Location src/Serilog.Formatting.Compact
10+
11+
& dotnet pack -c Release -o ..\..\.\artifacts --version-suffix=$revision
12+
if($LASTEXITCODE -ne 0) { exit 1 }
13+
14+
Pop-Location
15+
Push-Location test/Serilog.Formatting.Compact.Tests
16+
17+
& dotnet test -c Release
18+
if($LASTEXITCODE -ne 0) { exit 2 }
19+
20+
Pop-Location
21+
Pop-Location

CHANGES.md

Whitespace-only changes.

appveyor.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
version: '{build}'
2+
image: Visual Studio 2015
3+
configuration: Release
4+
install:
5+
- ps: mkdir -Force ".\build\" | Out-Null
6+
- ps: Invoke-WebRequest "https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0/scripts/obtain/dotnet-install.ps1" -OutFile ".\build\installcli.ps1"
7+
- ps: $env:DOTNET_INSTALL_DIR = "$pwd\.dotnetcli"
8+
- ps: '& .\build\installcli.ps1 -InstallDir "$env:DOTNET_INSTALL_DIR" -NoPath -Version 1.0.0-preview2-002823'
9+
- ps: $env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path"
10+
build_script:
11+
- ps: ./Build.ps1
12+
test: off
13+
artifacts:
14+
- path: artifacts/Serilog.*.nupkg
15+
deploy:
16+
- provider: NuGet
17+
api_key:
18+
secure: /Dm+EI0E1vCa+rZfYkluSnk7iSnAFKNOcEpreQrG88uYqCm//dKpY5vwqb1EJm3j
19+
skip_symbols: true
20+
on:
21+
branch: /^(dev|master)$/
22+

assets/Serilog.snk

596 Bytes
Binary file not shown.

global.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"projects": [ "src", "test" ],
3+
"sdk": {
4+
"version": "1.0.0-preview1-002702"
5+
}
6+
}

serilog-formatting-compact.sln

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.25123.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{037440DE-440B-4129-9F7A-09B42D00397E}"
7+
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "assets", "assets", "{E9D1B5E1-DEB9-4A04-8BAB-24EC7240ADAF}"
9+
ProjectSection(SolutionItems) = preProject
10+
appveyor.yml = appveyor.yml
11+
Build.ps1 = Build.ps1
12+
CHANGES.md = CHANGES.md
13+
global.json = global.json
14+
README.md = README.md
15+
assets\Serilog.snk = assets\Serilog.snk
16+
EndProjectSection
17+
EndProject
18+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{67B1C971-75EE-4ABE-B184-66AAC8D9D572}"
19+
EndProject
20+
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Serilog.Formatting.Compact", "src\Serilog.Formatting.Compact\Serilog.Formatting.Compact.xproj", "{D8A74F4C-981B-41F1-B807-FE08DFCC06D4}"
21+
EndProject
22+
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Serilog.Formatting.Compact.Tests", "test\Serilog.Formatting.Compact.Tests\Serilog.Formatting.Compact.Tests.xproj", "{3C2D8E01-5580-426A-BDD9-EC59CD98E618}"
23+
EndProject
24+
Global
25+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
26+
Debug|Any CPU = Debug|Any CPU
27+
Release|Any CPU = Release|Any CPU
28+
EndGlobalSection
29+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
30+
{D8A74F4C-981B-41F1-B807-FE08DFCC06D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31+
{D8A74F4C-981B-41F1-B807-FE08DFCC06D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
32+
{D8A74F4C-981B-41F1-B807-FE08DFCC06D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
33+
{D8A74F4C-981B-41F1-B807-FE08DFCC06D4}.Release|Any CPU.Build.0 = Release|Any CPU
34+
{3C2D8E01-5580-426A-BDD9-EC59CD98E618}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35+
{3C2D8E01-5580-426A-BDD9-EC59CD98E618}.Debug|Any CPU.Build.0 = Debug|Any CPU
36+
{3C2D8E01-5580-426A-BDD9-EC59CD98E618}.Release|Any CPU.ActiveCfg = Release|Any CPU
37+
{3C2D8E01-5580-426A-BDD9-EC59CD98E618}.Release|Any CPU.Build.0 = Release|Any CPU
38+
EndGlobalSection
39+
GlobalSection(SolutionProperties) = preSolution
40+
HideSolutionNode = FALSE
41+
EndGlobalSection
42+
GlobalSection(NestedProjects) = preSolution
43+
{D8A74F4C-981B-41F1-B807-FE08DFCC06D4} = {037440DE-440B-4129-9F7A-09B42D00397E}
44+
{3C2D8E01-5580-426A-BDD9-EC59CD98E618} = {67B1C971-75EE-4ABE-B184-66AAC8D9D572}
45+
EndGlobalSection
46+
EndGlobal
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
// Copyright 2016 Serilog Contributors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
using System;
16+
using System.IO;
17+
using System.Linq;
18+
using Serilog.Events;
19+
using Serilog.Formatting.Json;
20+
using Serilog.Parsing;
21+
22+
namespace Serilog.Formatting.Compact
23+
{
24+
/// <summary>
25+
/// An <see cref="ITextFormatter"/> that writes events in a compact JSON format.
26+
/// </summary>
27+
public class CompactJsonFormatter: ITextFormatter
28+
{
29+
readonly JsonValueFormatter _valueFormatter;
30+
31+
/// <summary>
32+
/// Construct a <see cref="CompactJsonFormatter"/>, optionally supplying a formatter for
33+
/// <see cref="LogEventPropertyValue"/>s on the event.
34+
/// </summary>
35+
/// <param name="valueFormatter">A value formatter, or null.</param>
36+
public CompactJsonFormatter(JsonValueFormatter valueFormatter = null)
37+
{
38+
_valueFormatter = valueFormatter ?? new JsonValueFormatter(typeTagName: "$type");
39+
}
40+
41+
/// <summary>
42+
/// Format the log event into the output. Subsequent events will be newline-delimited.
43+
/// </summary>
44+
/// <param name="logEvent">The event to format.</param>
45+
/// <param name="output">The output.</param>
46+
public void Format(LogEvent logEvent, TextWriter output)
47+
{
48+
FormatEvent(logEvent, output, _valueFormatter);
49+
output.WriteLine();
50+
}
51+
52+
/// <summary>
53+
/// Format the log event into the output.
54+
/// </summary>
55+
/// <param name="logEvent">The event to format.</param>
56+
/// <param name="output">The output.</param>
57+
/// <param name="valueFormatter">A value formatter for <see cref="LogEventPropertyValue"/>s on the event.</param>
58+
public static void FormatEvent(LogEvent logEvent, TextWriter output, JsonValueFormatter valueFormatter)
59+
{
60+
if (logEvent == null) throw new ArgumentNullException(nameof(logEvent));
61+
if (output == null) throw new ArgumentNullException(nameof(output));
62+
if (valueFormatter == null) throw new ArgumentNullException(nameof(valueFormatter));
63+
64+
output.Write("{\"@t\":\"");
65+
output.Write(logEvent.Timestamp.ToString("O"));
66+
output.Write("\",\"@mt\":");
67+
JsonValueFormatter.WriteQuotedJsonString(logEvent.MessageTemplate.Text, output);
68+
69+
var tokensWithFormat = logEvent.MessageTemplate.Tokens
70+
.OfType<PropertyToken>()
71+
.Where(pt => pt.Format != null);
72+
73+
// Better not to allocate an array in the 99.9% of cases where this is false
74+
// ReSharper disable once PossibleMultipleEnumeration
75+
if (tokensWithFormat.Any())
76+
{
77+
output.Write(",\"@r\":[");
78+
var delim = "";
79+
foreach (var r in tokensWithFormat)
80+
{
81+
output.Write(delim);
82+
delim = ",";
83+
var space = new StringWriter();
84+
r.Render(logEvent.Properties, space);
85+
JsonValueFormatter.WriteQuotedJsonString(space.ToString(), output);
86+
}
87+
output.Write(']');
88+
}
89+
90+
if (logEvent.Level != LogEventLevel.Information)
91+
{
92+
output.Write(",\"@l\":\"");
93+
output.Write(logEvent.Level);
94+
output.Write('\"');
95+
}
96+
97+
if (logEvent.Exception != null)
98+
{
99+
output.Write(",\"@x\":");
100+
JsonValueFormatter.WriteQuotedJsonString(logEvent.Exception.ToString(), output);
101+
}
102+
103+
foreach (var property in logEvent.Properties)
104+
{
105+
output.Write(',');
106+
JsonValueFormatter.WriteQuotedJsonString(property.Key, output);
107+
output.Write(':');
108+
valueFormatter.Format(property.Value, output);
109+
}
110+
111+
output.Write('}');
112+
}
113+
}
114+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
4+
[assembly: AssemblyTitle("Serilog.Formatting.Compact")]
5+
[assembly: AssemblyDescription("A simple, compact JSON-based event format for Serilog.")]
6+
[assembly: AssemblyCopyright("Copyright © Serilog Contributors 2013-2016")]
7+
[assembly: InternalsVisibleTo("Serilog.Formatting.Compact.Tests, PublicKey=" +
8+
"0024000004800000940000000602000000240000525341310004000001000100fb8d13fd344a1c" +
9+
"6fe0fe83ef33c1080bf30690765bc6eb0df26ebfdf8f21670c64265b30db09f73a0dea5b3db4c9" +
10+
"d18dbf6d5a25af5ce9016f281014d79dc3b4201ac646c451830fc7e61a2dfd633d34c39f87b818" +
11+
"94191652df5ac63cc40c77f3542f702bda692e6e8a9158353df189007a49da0f3cfd55eb250066" +
12+
"b19485ec")]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
5+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
6+
</PropertyGroup>
7+
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
8+
<PropertyGroup Label="Globals">
9+
<ProjectGuid>d8a74f4c-981b-41f1-b807-fe08dfcc06d4</ProjectGuid>
10+
<RootNamespace>Serilog</RootNamespace>
11+
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
12+
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
13+
</PropertyGroup>
14+
<PropertyGroup>
15+
<SchemaVersion>2.0</SchemaVersion>
16+
</PropertyGroup>
17+
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
18+
</Project>

0 commit comments

Comments
 (0)