Skip to content

Commit 06d4f4b

Browse files
committed
Removed failurecallback option.
1 parent b6e3968 commit 06d4f4b

File tree

5 files changed

+3
-43
lines changed

5 files changed

+3
-43
lines changed

src/Serilog.Sinks.Postgresql.Alternative.IntegrationTests/DbWriteTests.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,7 @@ public async Task TestIssue32()
445445
TableName,
446446
columnProps,
447447
needAutoCreateTable: true,
448-
needAutoCreateSchema: true,
449-
failureCallback: e => Console.WriteLine($"Sink error: {e.Message}")
448+
needAutoCreateSchema: true
450449
).CreateLogger();
451450

452451
LogContext.PushProperty("UserName", "Hans");
@@ -483,8 +482,7 @@ public async Task TestIssue52()
483482
TableName,
484483
columnProps,
485484
needAutoCreateTable: true,
486-
needAutoCreateSchema: true,
487-
failureCallback: e => Console.WriteLine($"Sink error: {e.Message}")
485+
needAutoCreateSchema: true
488486
).CreateLogger();
489487

490488
LogContext.PushProperty("EnumTest", DummyEnum.Test1);

src/Serilog.Sinks.Postgresql.Alternative.IntegrationTests/JsonConfigTestNamedConnectionString.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ public async Task ShouldCreateLoggerFromConfig()
5454
string.Empty,
5555
true,
5656
false,
57-
null,
5857
configuration).CreateLogger();
5958

6059
const long RowsCount = 2;

src/Serilog.Sinks.Postgresql.Alternative/LoggerConfigurationPostgreSQLExtensions.cs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ private static readonly IMicrosoftExtensionsConnectionStringProvider MicrosoftEx
5555
/// <param name="schemaName">The schema name.</param>
5656
/// <param name="needAutoCreateTable">A <seealso cref="bool"/> value indicating whether the table should be auto created or not.</param>
5757
/// <param name="needAutoCreateSchema">Specifies whether the schema should be auto-created if it does not already exist or not.</param>
58-
/// <param name="failureCallback">The failure callback.</param>
5958
/// <param name="appConfiguration">The app configuration section. Required if the connection string is a name.</param>
6059
/// <param name="onCreateTableCallback">The on create table callback.</param>
6160
/// <param name="onCreateSchemaCallback">The on create schema callback.</param>
@@ -76,7 +75,6 @@ public static LoggerConfiguration PostgreSQL(
7675
string schemaName = "",
7776
bool needAutoCreateTable = false,
7877
bool needAutoCreateSchema = false,
79-
Action<Exception>? failureCallback = null,
8078
IConfiguration? appConfiguration = null,
8179
Action<CreateTableEventArgs>? onCreateTableCallback = null,
8280
Action<CreateSchemaEventArgs>? onCreateSchemaCallback = null,
@@ -107,7 +105,6 @@ public static LoggerConfiguration PostgreSQL(
107105
schemaName,
108106
needAutoCreateTable,
109107
needAutoCreateSchema,
110-
failureCallback,
111108
onCreateTableCallback,
112109
onCreateSchemaCallback,
113110
retentionTime);
@@ -140,7 +137,6 @@ public static LoggerConfiguration PostgreSQL(
140137
/// <param name="schemaName">The schema name.</param>
141138
/// <param name="needAutoCreateTable">A <seealso cref="bool"/> value indicating whether the table should be auto created or not.</param>
142139
/// <param name="needAutoCreateSchema">Specifies whether the schema should be auto-created if it does not already exist or not.</param>
143-
/// <param name="failureCallback">The failure callback.</param>
144140
/// <param name="appConfiguration">The app configuration section. Required if the connection string is a name.</param>
145141
/// <param name="onCreateTableCallback">The on create table callback.</param>
146142
/// <param name="onCreateSchemaCallback">The on create schema callback.</param>
@@ -162,7 +158,6 @@ public static LoggerConfiguration PostgreSQL(
162158
string schemaName = "",
163159
bool needAutoCreateTable = false,
164160
bool needAutoCreateSchema = false,
165-
Action<Exception>? failureCallback = null,
166161
IConfiguration? appConfiguration = null,
167162
Action<CreateTableEventArgs>? onCreateTableCallback = null,
168163
Action<CreateSchemaEventArgs>? onCreateSchemaCallback = null,
@@ -238,7 +233,6 @@ public static LoggerConfiguration PostgreSQL(
238233
schemaName,
239234
needAutoCreateTable,
240235
needAutoCreateSchema,
241-
failureCallback,
242236
onCreateTableCallback,
243237
onCreateSchemaCallback,
244238
retentionTime);
@@ -272,7 +266,6 @@ public static LoggerConfiguration PostgreSQL(
272266
schemaName,
273267
needAutoCreateTable,
274268
needAutoCreateSchema,
275-
failureCallback,
276269
onCreateTableCallback,
277270
onCreateSchemaCallback);
278271

@@ -300,7 +293,6 @@ public static LoggerConfiguration PostgreSQL(
300293
/// <param name="schemaName">The schema name.</param>
301294
/// <param name="needAutoCreateTable">A <seealso cref="bool"/> value indicating whether the table should be auto created or not.</param>
302295
/// <param name="needAutoCreateSchema">Specifies whether the schema should be auto-created if it does not already exist or not.</param>
303-
/// <param name="failureCallback">The failure callback.</param>
304296
/// <param name="appConfiguration">The app configuration section. Required if the connection string is a name.</param>
305297
/// <param name="onCreateTableCallback">The on create table callback.</param>
306298
/// <param name="onCreateSchemaCallback">The on create schema callback.</param>
@@ -317,7 +309,6 @@ public static LoggerConfiguration PostgreSQL(
317309
string schemaName = "",
318310
bool needAutoCreateTable = false,
319311
bool needAutoCreateSchema = false,
320-
Action<Exception>? failureCallback = null,
321312
IConfiguration? appConfiguration = null,
322313
Action<CreateTableEventArgs>? onCreateTableCallback = null,
323314
Action<CreateSchemaEventArgs>? onCreateSchemaCallback = null,
@@ -346,7 +337,6 @@ public static LoggerConfiguration PostgreSQL(
346337
schemaName,
347338
needAutoCreateTable,
348339
needAutoCreateSchema,
349-
failureCallback,
350340
onCreateTableCallback,
351341
onCreateSchemaCallback,
352342
retentionTime);
@@ -391,7 +381,6 @@ internal static IDictionary<string, ColumnWriterBase> ClearQuotationMarksFromCol
391381
/// <param name="schemaName">The schema name.</param>
392382
/// <param name="needAutoCreateTable">A <seealso cref="bool"/> value indicating whether the table should be auto created or not.</param>
393383
/// <param name="needAutoCreateSchema">Specifies whether the schema should be auto-created if it does not already exist or not.</param>
394-
/// <param name="failureCallback">The failure callback.</param>
395384
/// <param name="appConfiguration">The app configuration section. Required if the connection string is a name.</param>
396385
/// <param name="onCreateTableCallback">The on create table callback.</param>
397386
/// <param name="onCreateSchemaCallback">The on create schema callback.</param>
@@ -409,7 +398,6 @@ public static LoggerConfiguration PostgreSQL(
409398
string schemaName = "",
410399
bool needAutoCreateTable = false,
411400
bool needAutoCreateSchema = false,
412-
Action<Exception>? failureCallback = null,
413401
IConfiguration? appConfiguration = null,
414402
Action<CreateTableEventArgs>? onCreateTableCallback = null,
415403
Action<CreateSchemaEventArgs>? onCreateSchemaCallback = null,
@@ -483,7 +471,6 @@ public static LoggerConfiguration PostgreSQL(
483471
schemaName,
484472
needAutoCreateTable,
485473
needAutoCreateSchema,
486-
failureCallback,
487474
onCreateTableCallback,
488475
onCreateSchemaCallback,
489476
retentionTime);
@@ -510,7 +497,6 @@ public static LoggerConfiguration PostgreSQL(
510497
schemaName,
511498
needAutoCreateTable,
512499
needAutoCreateSchema,
513-
failureCallback,
514500
onCreateTableCallback,
515501
onCreateSchemaCallback,
516502
retentionTime);
@@ -532,7 +518,6 @@ public static LoggerConfiguration PostgreSQL(
532518
/// <param name="schemaName">The schema name.</param>
533519
/// <param name="needAutoCreateTable">A <seealso cref="bool"/> value indicating whether the table should be auto created or not.</param>
534520
/// <param name="needAutoCreateSchema">Specifies whether the schema should be auto-created if it does not already exist or not.</param>
535-
/// <param name="failureCallback">The failure callback.</param>
536521
/// <param name="onCreateTableCallback">The on create table callback.</param>
537522
/// <param name="onCreateSchemaCallback">The on create schema callback.</param>
538523
/// <param name="retentionTime">The retention time of the log entries in the database.</param>
@@ -548,14 +533,12 @@ internal static PostgreSqlOptions GetOptions(
548533
string schemaName,
549534
bool needAutoCreateTable,
550535
bool needAutoCreateSchema,
551-
Action<Exception>? failureCallback,
552536
Action<CreateTableEventArgs>? onCreateTableCallback,
553537
Action<CreateSchemaEventArgs>? onCreateSchemaCallback,
554538
TimeSpan? retentionTime = null)
555539
{
556540
var columnOptionsLocal = ClearQuotationMarksFromColumnOptions(columnOptions ?? ColumnOptions.Default);
557541

558-
#pragma warning disable CS0618 // Typ oder Element ist veraltet
559542
return new PostgreSqlOptions
560543
{
561544
ConnectionString = connectionString,
@@ -569,12 +552,9 @@ internal static PostgreSqlOptions GetOptions(
569552
SchemaName = schemaName.Replace("\"", string.Empty),
570553
NeedAutoCreateTable = needAutoCreateTable,
571554
NeedAutoCreateSchema = needAutoCreateSchema,
572-
// Todo: Remove this in next version!
573-
FailureCallback = failureCallback,
574555
OnCreateTable = onCreateTableCallback,
575556
OnCreateSchema = onCreateSchemaCallback,
576557
RetentionTime = retentionTime
577558
};
578-
#pragma warning restore CS0618 // Typ oder Element ist veraltet
579559
}
580560
}

src/Serilog.Sinks.Postgresql.Alternative/Sinks/PostgreSQL/PostgreSQLOptions.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@ public sealed class PostgreSqlOptions
3939
/// </summary>
4040
public bool UseCopy { get; set; }
4141

42-
/// <summary>
43-
/// Gets or sets the failure callback.
44-
/// </summary>
45-
[Obsolete("Use fallback logging instead. Check https://nblumhardt.com/2024/10/fallback-logging/.")]
46-
public Action<Exception>? FailureCallback { get; set; }
47-
4842
/// <summary>
4943
/// Gets or sets the column options.
5044
/// </summary>

src/Serilog.Sinks.Postgresql.Alternative/Sinks/PostgreSQL/PostgreSQLSink.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,7 @@ public PostgreSqlSink(PostgreSqlOptions options)
4444
/// </remarks>
4545
public async Task EmitBatchAsync(IReadOnlyCollection<LogEvent> events)
4646
{
47-
try
48-
{
49-
await this.sinkHelper.Emit(events);
50-
}
51-
catch (Exception ex)
52-
{
53-
// Todo: Remove this in next version!
54-
#pragma warning disable CS0618 // Typ oder Element ist veraltet
55-
this.sinkHelper.SinkOptions.FailureCallback?.Invoke(ex);
56-
#pragma warning restore CS0618 // Typ oder Element ist veraltet
57-
throw;
58-
}
47+
await this.sinkHelper.Emit(events);
5948
}
6049

6150
/// <inheritdoc cref="IBatchedLogEventSink" />

0 commit comments

Comments
 (0)