More Logging

This commit is contained in:
glax 2023-08-27 01:22:08 +02:00
parent bbd716383a
commit 2fcab1f1b1
6 changed files with 15 additions and 10 deletions

View File

@ -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);
}

View File

@ -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<Job> jobs)
public void RemoveJobs(IEnumerable<Job> 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<Job> GetJobsLike(string? connectorName = null, string? internalId = null, string? chapterNumber = null)

View File

@ -42,7 +42,7 @@ public class Kavita : LibraryConnector
JsonObject? result = JsonSerializer.Deserialize<JsonObject>(response.Content.ReadAsStream());
if (result is not null)
return result["token"]!.GetValue<string>();
else return "";
else throw new Exception("Did not receive token.");
}
public override void UpdateLibrary()

View File

@ -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)

View File

@ -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()}");
}
}

View File

@ -397,9 +397,9 @@ public class Server : GlobalBase
: Array.Empty<byte>());
response.OutputStream.Close();
}
catch (HttpListenerException)
catch (HttpListenerException e)
{
Log(e.ToString());
}
}
}