diff --git a/Tranga/GlobalBase.cs b/Tranga/GlobalBase.cs index a37fd5e..20e41b5 100644 --- a/Tranga/GlobalBase.cs +++ b/Tranga/GlobalBase.cs @@ -49,6 +49,7 @@ public abstract class GlobalBase protected void AddNotificationConnector(NotificationConnector notificationConnector) { + Log($"Adding {notificationConnector}"); notificationConnectors.RemoveWhere(nc => nc.GetType() == notificationConnector.GetType()); notificationConnectors.Add(notificationConnector); @@ -59,6 +60,7 @@ public abstract class GlobalBase protected void DeleteNotificationConnector(NotificationConnector.NotificationManagerType notificationManagerType) { + Log($"Removing {notificationManagerType}"); notificationConnectors.RemoveWhere(nc => nc.notificationManagerType == notificationManagerType); } @@ -70,6 +72,7 @@ public abstract class GlobalBase protected void AddLibraryConnector(LibraryConnector libraryConnector) { + Log($"Adding {libraryConnector}"); libraryConnectors.RemoveWhere(lc => lc.GetType() == libraryConnector.GetType()); libraryConnectors.Add(libraryConnector); @@ -80,6 +83,7 @@ public abstract class GlobalBase protected void DeleteLibraryConnector(LibraryConnector.LibraryType libraryType) { + Log($"Removing {libraryType}"); libraryConnectors.RemoveWhere(lc => lc.libraryType == libraryType); } diff --git a/Tranga/Jobs/JobBoss.cs b/Tranga/Jobs/JobBoss.cs index 5838c7a..614f85f 100644 --- a/Tranga/Jobs/JobBoss.cs +++ b/Tranga/Jobs/JobBoss.cs @@ -15,22 +15,22 @@ public class JobBoss : GlobalBase public void AddJob(Job job) { + Log($"Added {job}"); this.jobs.Add(job); } public void RemoveJob(Job job) { + Log($"Removing {job}"); job.Cancel(); this.jobs.Remove(job); } - public void RemoveJobs(IEnumerable jobs) + public void RemoveJobs(IEnumerable jobsToRemove) { - foreach (Job job in jobs) - { - job.Cancel(); - this.jobs.Remove(job); - } + Log($"Removing {jobsToRemove.Count()} jobs."); + foreach (Job job in jobsToRemove) + RemoveJob(job); } public IEnumerable GetJobsLike(string? connectorName = null, string? internalId = null, string? chapterNumber = null) diff --git a/Tranga/LibraryConnectors/Kavita.cs b/Tranga/LibraryConnectors/Kavita.cs index a42f691..a6442f2 100644 --- a/Tranga/LibraryConnectors/Kavita.cs +++ b/Tranga/LibraryConnectors/Kavita.cs @@ -42,7 +42,7 @@ public class Kavita : LibraryConnector JsonObject? result = JsonSerializer.Deserialize(response.Content.ReadAsStream()); if (result is not null) return result["token"]!.GetValue(); - else return ""; + else throw new Exception("Did not receive token."); } public override void UpdateLibrary() diff --git a/Tranga/MangaConnectors/DownloadClient.cs b/Tranga/MangaConnectors/DownloadClient.cs index c34ab25..2bd244c 100644 --- a/Tranga/MangaConnectors/DownloadClient.cs +++ b/Tranga/MangaConnectors/DownloadClient.cs @@ -60,6 +60,7 @@ internal class DownloadClient : GlobalBase if(referrer is not null) requestMessage.Headers.Referrer = new Uri(referrer); _lastExecutedRateLimit[requestType] = DateTime.Now; + Log($"Requesting {requestType} {url}"); response = Client.Send(requestMessage); } catch (HttpRequestException e) diff --git a/Tranga/NotificationConnectors/Gotify.cs b/Tranga/NotificationConnectors/Gotify.cs index 53996a5..306663f 100644 --- a/Tranga/NotificationConnectors/Gotify.cs +++ b/Tranga/NotificationConnectors/Gotify.cs @@ -33,7 +33,7 @@ public class Gotify : NotificationConnector if (!response.IsSuccessStatusCode) { StreamReader sr = new (response.Content.ReadAsStream()); - logger?.WriteLine(this.GetType().ToString(), $"{response.StatusCode}: {sr.ReadToEnd()}"); + Log($"{response.StatusCode}: {sr.ReadToEnd()}"); } } diff --git a/Tranga/Server.cs b/Tranga/Server.cs index 50d16b4..d0494f9 100644 --- a/Tranga/Server.cs +++ b/Tranga/Server.cs @@ -397,9 +397,9 @@ public class Server : GlobalBase : Array.Empty()); response.OutputStream.Close(); } - catch (HttpListenerException) + catch (HttpListenerException e) { - + Log(e.ToString()); } } } \ No newline at end of file