Skip to content

Commit

Permalink
Merge pull request #602 from ckadluba/remove-exception-handlers
Browse files Browse the repository at this point in the history
Remove obsolete exception handlers
  • Loading branch information
ckadluba authored Nov 22, 2024
2 parents 1ad392b + 8db2905 commit dea6326
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 29 deletions.
3 changes: 1 addition & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# 8.1.0
* Implemented #542: Column option `ResolveHierarchicalPropertyName` to force non-hierarchical handling

# 8.0.1
* Removed unnecessary exception handlers and let Serilog Core do the SelfLog()
* Refactoring and performance optimizations in batched and audit sink
* Create perftest result on release
* Updated issue template
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,6 @@ public async Task WriteBatch(IEnumerable<LogEvent> events)
}
}
}
catch (Exception ex)
{
SelfLog.WriteLine("Unable to write batch of {0} log events to the database due to following error: {1}",
events.Count(), ex);
throw;
}
finally
{
_dataTable.Clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,34 +43,26 @@ public SqlInsertStatementWriter(

public async Task WriteEvents(IEnumerable<LogEvent> events)
{
try
using (var cn = _sqlConnectionFactory.Create())
{
using (var cn = _sqlConnectionFactory.Create())
await cn.OpenAsync().ConfigureAwait(false);

foreach (var logEvent in events)
{
await cn.OpenAsync().ConfigureAwait(false);
var fields = _logEventDataGenerator.GetColumnsAndValues(logEvent).ToList();
InitializeSqlCommand(cn, fields);

foreach (var logEvent in events)
var index = 0;
_sqlCommand.ClearParameters();
foreach (var field in fields)
{
var fields = _logEventDataGenerator.GetColumnsAndValues(logEvent).ToList();
InitializeSqlCommand(cn, fields);

var index = 0;
_sqlCommand.ClearParameters();
foreach (var field in fields)
{
_sqlCommand.AddParameter(Invariant($"@P{index}"), field.Value);
index++;
}

await _sqlCommand.ExecuteNonQueryAsync().ConfigureAwait(false);
_sqlCommand.AddParameter(Invariant($"@P{index}"), field.Value);
index++;
}

await _sqlCommand.ExecuteNonQueryAsync().ConfigureAwait(false);
}
}
catch (Exception ex)
{
SelfLog.WriteLine("Unable to write log event to the database due to following error: {0}", ex);
throw;
}
}

/// <summary>
Expand Down

0 comments on commit dea6326

Please sign in to comment.