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

Commit a01baff

Browse files
authored
Added original exception to FailureCallback action (#449)
1 parent fef527b commit a01baff

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

sample/Serilog.Sinks.Elasticsearch.Sample/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static void Main(string[] args)
4040
NumberOfShards = 2,
4141
//BufferBaseFilename = "./buffer",
4242
// RegisterTemplateFailure = RegisterTemplateRecovery.FailSink,
43-
FailureCallback = e => Console.WriteLine("Unable to submit event " + e.MessageTemplate),
43+
FailureCallback = (e, ex) => Console.WriteLine("Unable to submit event " + e.MessageTemplate),
4444
EmitEventFailure = EmitEventFailureHandling.WriteToSelfLog |
4545
EmitEventFailureHandling.WriteToFailureSink |
4646
EmitEventFailureHandling.RaiseCallback,

src/Serilog.Sinks.Elasticsearch/Sinks/ElasticSearch/ElasticSearchSink.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ private void HandleException(Exception ex, IEnumerable<LogEvent> events)
142142
{
143143
foreach (var e in events)
144144
{
145-
_state.Options.FailureCallback(e);
145+
_state.Options.FailureCallback(e, ex);
146146
}
147147
}
148148
catch (Exception exCallback)
@@ -233,7 +233,7 @@ private void HandleResponse(IEnumerable<LogEvent> events, DynamicResponse result
233233
// Send to a failure callback
234234
try
235235
{
236-
_state.Options.FailureCallback(e);
236+
_state.Options.FailureCallback(e, null);
237237
}
238238
catch (Exception ex)
239239
{

src/Serilog.Sinks.Elasticsearch/Sinks/ElasticSearch/ElasticsearchSinkOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ public class ElasticsearchSinkOptions
246246
/// A callback which can be used to handle logevents which are not submitted to Elasticsearch
247247
/// like when it is unable to accept the events. This is optional and depends on the EmitEventFailure setting.
248248
/// </summary>
249-
public Action<LogEvent> FailureCallback { get; set; }
249+
public Action<LogEvent, Exception> FailureCallback { get; set; }
250250

251251
/// <summary>
252252
/// The maximum number of events that will be held in-memory while waiting to ship them to

0 commit comments

Comments
 (0)