Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Rid out ElasticSearch.Net dependency from Serilog.Formatting.Elasticsearch package #231

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 3 additions & 25 deletions src/Serilog.Formatting.Elasticsearch/ElasticsearchJsonFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
using System.IO;
using System.Linq;
using System.Reflection;
#if !NO_SERIALIZATION
using System.Runtime.Serialization;
using Elasticsearch.Net;
#endif
using Serilog.Events;
using Serilog.Parsing;

Expand All @@ -30,7 +31,6 @@ namespace Serilog.Formatting.Elasticsearch
/// </summary>
public class ElasticsearchJsonFormatter : DefaultJsonFormatter
{
readonly IElasticsearchSerializer _serializer;
readonly bool _inlineFields;
readonly bool _formatStackTraceAsArray;

Expand Down Expand Up @@ -67,23 +67,19 @@ public class ElasticsearchJsonFormatter : DefaultJsonFormatter
/// <param name="renderMessage">If true, the message will be rendered and written to the output as a
/// property named RenderedMessage.</param>
/// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
/// <param name="serializer">Inject a serializer to force objects to be serialized over being ToString()</param>
/// <param name="inlineFields">When set to true values will be written at the root of the json document</param>
/// <param name="renderMessageTemplate">If true, the message template will be rendered and written to the output as a
/// <param name="renderMessageTemplate">If true, the message template will be rendered and written to the output as a property named RenderedMessageTemplate.</param>
/// <param name="formatStackTraceAsArray">If true, splits the StackTrace by new line and writes it as a an array of strings</param>
/// property named RenderedMessageTemplate.</param>
public ElasticsearchJsonFormatter(
bool omitEnclosingObject = false,
string closingDelimiter = null,
bool renderMessage = true,
IFormatProvider formatProvider = null,
IElasticsearchSerializer serializer = null,
bool inlineFields = false,
bool renderMessageTemplate = true,
bool formatStackTraceAsArray = false)
: base(omitEnclosingObject, closingDelimiter, renderMessage, formatProvider, renderMessageTemplate)
{
_serializer = serializer;
_inlineFields = inlineFields;
_formatStackTraceAsArray = formatStackTraceAsArray;
}
Expand Down Expand Up @@ -313,23 +309,5 @@ protected override void WriteTimestamp(DateTimeOffset timestamp, ref string deli
{
WriteJsonProperty(TimestampPropertyName, timestamp, ref delim, output);
}

/// <summary>
/// Allows a subclass to write out objects that have no configured literal writer.
/// </summary>
/// <param name="value">The value to be written as a json construct</param>
/// <param name="output">The writer to write on</param>
protected override void WriteLiteralValue(object value, TextWriter output)
{
if (_serializer != null)
{
string jsonString = _serializer.SerializeToString(value, SerializationFormatting.None);
output.Write(jsonString);
return;
}

base.WriteLiteralValue(value, output);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

using System;
using System.IO;
using Elasticsearch.Net;

namespace Serilog.Formatting.Elasticsearch
{
Expand All @@ -41,17 +40,15 @@ public class ExceptionAsObjectJsonFormatter : ElasticsearchJsonFormatter
/// <param name="renderMessage">If true, the message will be rendered and written to the output as a
/// property named RenderedMessage.</param>
/// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
/// <param name="serializer">Inject a serializer to force objects to be serialized over being ToString()</param>
/// <param name="inlineFields">When set to true values will be written at the root of the json document</param>
/// <param name="formatStackTraceAsArray">If true, splits the StackTrace by new line and writes it as a an array of strings</param>
public ExceptionAsObjectJsonFormatter(bool omitEnclosingObject = false,
string closingDelimiter = null,
bool renderMessage = false,
IFormatProvider formatProvider = null,
IElasticsearchSerializer serializer = null,
IFormatProvider formatProvider = null,
bool inlineFields = false,
bool formatStackTraceAsArray = false)
: base(omitEnclosingObject, closingDelimiter, renderMessage, formatProvider, serializer, inlineFields, formatStackTraceAsArray)
: base(omitEnclosingObject, closingDelimiter, renderMessage, formatProvider, inlineFields, formatStackTraceAsArray)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
<iconUrl>http://serilog.net/images/serilog-sink-nuget.png</iconUrl>
<tags>serilog logging elasticsearch</tags>
<dependencies>
<dependency id="Serilog" version="2.6.0" />
<dependency id="Elasticsearch.Net" version="6.0.0" />
<dependency id="Serilog" version="2.8.0" />
</dependencies>
</metadata>
<files>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
<repository type="git" url="https://github.com/serilog/serilog-sinks-elasticsearch" />
<tags>serilog logging elasticsearch formatters</tags>
<dependencies>
<dependency id="Serilog" version="2.6.0" />
<dependency id="Elasticsearch.Net" version="6.0.0" />
<dependency id="Serilog" version="2.8.0" />
</dependencies>
</metadata>
<files>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Elasticsearch.Net" Version="6.0.0" />
<PackageReference Include="Serilog" Version="2.8.0" />
</ItemGroup>

Expand Down

This file was deleted.

This file was deleted.

Loading