diff --git a/SharpRss/DbAccess.cs b/SharpRss/DbAccess.cs index 1e6bf0c..eeab218 100644 --- a/SharpRss/DbAccess.cs +++ b/SharpRss/DbAccess.cs @@ -159,6 +159,7 @@ namespace SharpRss public static async Task DeleteSyndicationAsync(SyndicationModel syndication, bool deleteItems = false) { if (syndication == null) return false; + Log.Information("Removing syndication..."); await using SqliteConnection dbc = new SqliteConnection(ConnectionString); int affected = await dbc.ExecuteAsync("DELETE FROM syndication WHERE encoded_url=@EncodedUrl", new { EncodedUrl = syndication.EncodedUrl }); if (affected > 0 && deleteItems) @@ -168,6 +169,7 @@ namespace SharpRss public static async Task SetSyndicationItemsAsync(HashSet items) { + Log.Information("Inserting syndication items..."); await using SqliteConnection dbc = new SqliteConnection(ConnectionString); dbc.Open(); int totalAffected = 0; @@ -227,7 +229,7 @@ namespace SharpRss syndicationItemModel.SyndicationParent = TempCache.GetSyndication(syndicationItemModel.EncodedSyndicationUrl) ?? new SyndicationModel(); // The new syndication should never be initialized, if this hits then the date is not valid for some reason!!! items.Add(syndicationItemModel); } - Log.Debug("Fetching feed items resulted: {ItemCount} item(s)", items.Count); + Log.Information("Fetching feed items resulted: {ItemCount} item(s)", items.Count); return items; } public static async void Initialize() @@ -236,15 +238,15 @@ namespace SharpRss Log.Verbose("Checking database..."); await using SqliteConnection dbc = new SqliteConnection(ConnectionString); dbc.Open(); - Log.Verbose("Checking table: {Table}", "category"); + Log.Information("Checking table: {Table}", "category"); await dbc.ExecuteAsync("CREATE TABLE IF NOT EXISTS category (id STRING PRIMARY KEY, name STRING NOT NULL, hex_color STRING NOT NULL, icon STRING, last_updated INT)"); - Log.Verbose("Checking table: {Table}", "feed"); + Log.Information("Checking table: {Table}", "feed"); await dbc.ExecuteAsync("CREATE TABLE IF NOT EXISTS syndication (encoded_url STRING PRIMARY KEY, title STRING, category_id STRING, syndication_type STRING, version STRING, description STRING, language STRING, copyright STRING, last_updated INT, publication_date INT, syn_updated_date INT, categories STRING, image_url STRING)"); - Log.Verbose("Checking table: {Table}", "feed_item"); + Log.Information("Checking table: {Table}", "feed_item"); await dbc.ExecuteAsync("CREATE TABLE IF NOT EXISTS syndication_item (link STRING PRIMARY KEY, encoded_syndication_url STRING, read STRING, type STRING, title STRING, description STRING, last_updated INT, item_updated_date INT, publishing_date INT, authors STRING, categories STRING, content STRING, comments_url STRING)"); - Log.Verbose("Checking database done!"); + Log.Information("Checking database done!"); _isInitialized = true; } diff --git a/SharpRss/Services/SyndicationService.cs b/SharpRss/Services/SyndicationService.cs index cf16367..e61c0a9 100644 --- a/SharpRss/Services/SyndicationService.cs +++ b/SharpRss/Services/SyndicationService.cs @@ -15,6 +15,7 @@ namespace SharpRss.Services { public SyndicationService() { + Log.Information("Constructing SyndicationService..."); SetupTestCategoriesAndFeedsAsync(); } @@ -34,7 +35,7 @@ namespace SharpRss.Services var syndication = SyndicationManager.CreateSyndication(url); if (!syndication.Fetched) { - Log.Debug("Failed to fetch syndication feed!"); + Log.Warning("Failed to fetch syndication feed!"); return false; } if (category != null) @@ -51,7 +52,7 @@ namespace SharpRss.Services } public async Task UpdateFeeds() { - Log.Verbose("Fetching feeds..."); + Log.Information("Fetching feeds..."); var feeds = await GetFeedsAsync(); } public async Task> GetFeedsAsync(string? categoryId = null) => await DbAccess.GetSyndicationsAsync(categoryId == null ? null : new[]{ categoryId }); @@ -103,7 +104,8 @@ namespace SharpRss.Services } private async void SetupTestCategoriesAndFeedsAsync() { - /*try + Log.Information("Setting up test data..."); + try { CategoryModel? newsCategory = await CreateCategoryAsync(new CategoryModel() { Name = "News" }); if (newsCategory != null) @@ -113,7 +115,7 @@ namespace SharpRss.Services await AddSubscriptionAsync("https://www.nasa.gov/rss/dyn/breaking_news.rss", newsCategory); await AddSubscriptionAsync("http://news.google.com/?output=atom", newsCategory); } - + CategoryModel? techCategory = await CreateCategoryAsync(new CategoryModel() { Name = "Tech" }); if (techCategory != null) { @@ -142,7 +144,7 @@ namespace SharpRss.Services catch (Exception e) { Log.Error(e, "Exception!"); - }*/ + } } } } \ No newline at end of file diff --git a/SharpRss/SyndicationManager.cs b/SharpRss/SyndicationManager.cs index e6154ef..42df166 100644 --- a/SharpRss/SyndicationManager.cs +++ b/SharpRss/SyndicationManager.cs @@ -27,7 +27,7 @@ namespace SharpRss Uri feedUri = new Uri(feedUrl); try { - Log.Debug("Fetching syndication: {SyndicationUri}", feedUri.ToString()); + Log.Information("Fetching syndication: {SyndicationUri}", feedUri.ToString()); syndicationFeed = GenericSyndicationFeed.Create(feedUri); } catch (Exception e) diff --git a/WebSharpRSS/sharp_rss.sqlite b/WebSharpRSS/sharp_rss.sqlite index bd114dc..38040e1 100644 Binary files a/WebSharpRSS/sharp_rss.sqlite and b/WebSharpRSS/sharp_rss.sqlite differ