From 5330815e1bca62092957491a2199c1be6271641b Mon Sep 17 00:00:00 2001 From: Robin Dadswell <19610103+RobinDadswell@users.noreply.github.com> Date: Tue, 22 Nov 2022 00:05:55 +0000 Subject: [PATCH] fixup: some tests for log files --- src/NzbDrone.Core/Instrumentation/DatabaseTarget.cs | 9 ++++++--- src/NzbDrone.Test.Common/ExceptionVerification.cs | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/NzbDrone.Core/Instrumentation/DatabaseTarget.cs b/src/NzbDrone.Core/Instrumentation/DatabaseTarget.cs index 2f4cefdd5..02cb58231 100644 --- a/src/NzbDrone.Core/Instrumentation/DatabaseTarget.cs +++ b/src/NzbDrone.Core/Instrumentation/DatabaseTarget.cs @@ -97,6 +97,11 @@ namespace NzbDrone.Core.Instrumentation WritePostgresLog(log, connectionString); } } + catch (NpgsqlException ex) + { + InternalLogger.Error("Unable to save log event to database: {0}", ex); + throw; + } catch (SQLiteException ex) { InternalLogger.Error("Unable to save log event to database: {0}", ex); @@ -128,10 +133,8 @@ namespace NzbDrone.Core.Instrumentation private void WriteSqliteLog(Log log, string connectionString) { using (var connection = - new SQLiteConnection(_connectionStringFactory.LogDbConnectionString).OpenAndReturn()) + new SQLiteConnection(connectionString).OpenAndReturn()) { - connection.ConnectionString = connectionString; - connection.Open(); using (var sqlCommand = connection.CreateCommand()) { sqlCommand.CommandText = INSERT_COMMAND; diff --git a/src/NzbDrone.Test.Common/ExceptionVerification.cs b/src/NzbDrone.Test.Common/ExceptionVerification.cs index bcf417434..4ead02b8f 100644 --- a/src/NzbDrone.Test.Common/ExceptionVerification.cs +++ b/src/NzbDrone.Test.Common/ExceptionVerification.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Threading;