From 94e622e3a0cfcd14ad47ede3342dfab7a862c4d9 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 20 Nov 2016 16:02:32 -0500 Subject: [PATCH] add sqlite logging --- .../Data/BaseSqliteRepository.cs | 9 ++++ src/Emby.Server/CoreAppHost.cs | 7 +-- src/Emby.Server/Data/DbConnector.cs | 52 ------------------- src/Emby.Server/Program.cs | 3 +- 4 files changed, 12 insertions(+), 59 deletions(-) delete mode 100644 src/Emby.Server/Data/DbConnector.cs diff --git a/Emby.Server.Implementations/Data/BaseSqliteRepository.cs b/Emby.Server.Implementations/Data/BaseSqliteRepository.cs index 6c1a96813..7836c8b41 100644 --- a/Emby.Server.Implementations/Data/BaseSqliteRepository.cs +++ b/Emby.Server.Implementations/Data/BaseSqliteRepository.cs @@ -33,8 +33,17 @@ namespace Emby.Server.Implementations.Data //CheckOk(rc); } + private static bool _versionLogged; + protected virtual SQLiteDatabaseConnection CreateConnection(bool isReadOnly = false) { + if (!_versionLogged) + { + _versionLogged = true; + Logger.Info("Sqlite version: " + SQLite3.Version); + Logger.Info("Sqlite compiler options: " + string.Join(",", SQLite3.CompilerOptions.ToArray())); + } + ConnectionFlags connectionFlags; //isReadOnly = false; diff --git a/src/Emby.Server/CoreAppHost.cs b/src/Emby.Server/CoreAppHost.cs index 21f6ae445..5291f20ef 100644 --- a/src/Emby.Server/CoreAppHost.cs +++ b/src/Emby.Server/CoreAppHost.cs @@ -4,12 +4,12 @@ using System.Linq; using System.Reflection; using System.Threading.Tasks; using Emby.Server.Core; -using Emby.Server.Core.Data; using Emby.Server.Core.FFMpeg; using Emby.Server.Data; using MediaBrowser.Model.IO; using MediaBrowser.Model.Logging; using MediaBrowser.Model.System; +using Emby.Server.Implementations; namespace Emby.Server { @@ -55,11 +55,6 @@ namespace Emby.Server { } - protected override IDbConnector GetDbConnector() - { - return new DbConnector(Logger); - } - protected override void ConfigureAutoRunInternal(bool autorun) { } diff --git a/src/Emby.Server/Data/DbConnector.cs b/src/Emby.Server/Data/DbConnector.cs deleted file mode 100644 index bd70cff6c..000000000 --- a/src/Emby.Server/Data/DbConnector.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.Data; -using System.Threading.Tasks; -using MediaBrowser.Model.Logging; -using Emby.Server.Core.Data; -using Microsoft.Data.Sqlite; - -namespace Emby.Server.Data -{ - public class DbConnector : IDbConnector - { - private readonly ILogger _logger; - - public DbConnector(ILogger logger) - { - _logger = logger; - } - - public async Task Connect(string dbPath, bool isReadOnly, bool enablePooling = false, int? cacheSize = null) - { - if (string.IsNullOrEmpty(dbPath)) - { - throw new ArgumentNullException("dbPath"); - } - - //SQLiteConnection.SetMemoryStatus(false); - - var connectionstr = new SqliteConnectionStringBuilder - { - //PageSize = 4096, - //CacheSize = cacheSize ?? 2000, - //SyncMode = SynchronizationModes.Normal, - DataSource = dbPath, - //JournalMode = SQLiteJournalModeEnum.Wal, - - // This is causing crashing under linux - //Pooling = enablePooling && Environment.OSVersion.Platform == PlatformID.Win32NT, - //ReadOnly = isReadOnly, - Cache = enablePooling ? SqliteCacheMode.Default : SqliteCacheMode.Private, - Mode = isReadOnly ? SqliteOpenMode.ReadOnly : SqliteOpenMode.ReadWriteCreate - }; - - var connectionString = connectionstr.ConnectionString; - - var connection = new SqliteConnection(connectionString); - - await connection.OpenAsync().ConfigureAwait(false); - - return connection; - } - } -} \ No newline at end of file diff --git a/src/Emby.Server/Program.cs b/src/Emby.Server/Program.cs index 80e56c8ab..e5d8351fe 100644 --- a/src/Emby.Server/Program.cs +++ b/src/Emby.Server/Program.cs @@ -15,10 +15,11 @@ using Emby.Common.Implementations.Logging; using Emby.Common.Implementations.Networking; using Emby.Drawing; using Emby.Server.Core; -using Emby.Server.Core.Browser; +using Emby.Server.Implementations.Browser; using Emby.Server.Implementations.IO; using MediaBrowser.Common.Net; using Emby.Server.IO; +using Emby.Server.Implementations; namespace Emby.Server {