Logging Enhancements (#1521)

* Recreated Kavita Logging with Serilog instead of Default. This needs to be move out of the appsettings now, to allow auto updater to patch.

* Refactored the code to be completely configured via Code rather than appsettings.json. This is a required step for Auto Updating.

* Added in the ability to send logs directly to the UI only for users on the log route. Stopping implementation as Alerts page will handle the rest of the implementation.

* Fixed up the backup service to not rely on Config from appsettings.json

* Tweaked the Logging levels available

* Moved everything over to File-scoped namespaces

* Moved everything over to File-scoped namespaces

* Code cleanup, removed an old migration and changed so debug logging doesn't print sensitive db data

* Removed dead code
This commit is contained in:
Joseph Milazzo 2022-09-12 19:25:48 -05:00 committed by GitHub
parent 9f715cc35f
commit d1a14f7e68
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
212 changed files with 16599 additions and 16834 deletions

View file

@ -1,23 +1,22 @@
using System.ComponentModel;
namespace API.Entities.Enums
namespace API.Entities.Enums;
public enum LibraryType
{
public enum LibraryType
{
/// <summary>
/// Uses Manga regex for filename parsing
/// </summary>
[Description("Manga")]
Manga = 0,
/// <summary>
/// Uses Comic regex for filename parsing
/// </summary>
[Description("Comic")]
Comic = 1,
/// <summary>
/// Uses Manga regex for filename parsing also uses epub metadata
/// </summary>
[Description("Book")]
Book = 2,
}
/// <summary>
/// Uses Manga regex for filename parsing
/// </summary>
[Description("Manga")]
Manga = 0,
/// <summary>
/// Uses Comic regex for filename parsing
/// </summary>
[Description("Comic")]
Comic = 1,
/// <summary>
/// Uses Manga regex for filename parsing also uses epub metadata
/// </summary>
[Description("Book")]
Book = 2,
}

View file

@ -1,38 +1,37 @@
using System.ComponentModel;
namespace API.Entities.Enums
namespace API.Entities.Enums;
/// <summary>
/// Represents the format of the file
/// </summary>
public enum MangaFormat
{
/// <summary>
/// Represents the format of the file
/// Image file
/// See <see cref="Services.Tasks.Scanner.Parser.Parser.ImageFileExtensions"/> for supported extensions
/// </summary>
public enum MangaFormat
{
/// <summary>
/// Image file
/// See <see cref="Services.Tasks.Scanner.Parser.Parser.ImageFileExtensions"/> for supported extensions
/// </summary>
[Description("Image")]
Image = 0,
/// <summary>
/// Archive based file
/// See <see cref="Services.Tasks.Scanner.Parser.Parser.ArchiveFileExtensions"/> for supported extensions
/// </summary>
[Description("Archive")]
Archive = 1,
/// <summary>
/// Unknown. Not used.
/// </summary>
[Description("Unknown")]
Unknown = 2,
/// <summary>
/// EPUB File
/// </summary>
[Description("EPUB")]
Epub = 3,
/// <summary>
/// PDF File
/// </summary>
[Description("PDF")]
Pdf = 4
}
[Description("Image")]
Image = 0,
/// <summary>
/// Archive based file
/// See <see cref="Services.Tasks.Scanner.Parser.Parser.ArchiveFileExtensions"/> for supported extensions
/// </summary>
[Description("Archive")]
Archive = 1,
/// <summary>
/// Unknown. Not used.
/// </summary>
[Description("Unknown")]
Unknown = 2,
/// <summary>
/// EPUB File
/// </summary>
[Description("EPUB")]
Epub = 3,
/// <summary>
/// PDF File
/// </summary>
[Description("PDF")]
Pdf = 4
}

View file

@ -1,10 +1,9 @@
namespace API.Entities.Enums
namespace API.Entities.Enums;
public enum PageSplitOption
{
public enum PageSplitOption
{
SplitLeftToRight = 0,
SplitRightToLeft = 1,
NoSplit = 2,
FitSplit = 3
}
SplitLeftToRight = 0,
SplitRightToLeft = 1,
NoSplit = 2,
FitSplit = 3
}

View file

@ -1,31 +1,30 @@
namespace API.Entities.Enums
namespace API.Entities.Enums;
public enum PersonRole
{
public enum PersonRole
{
/// <summary>
/// Another role, not covered by other types
/// </summary>
Other = 1,
/// <summary>
/// Author or Writer
/// </summary>
Writer = 3,
Penciller = 4,
Inker = 5,
Colorist = 6,
Letterer = 7,
CoverArtist = 8,
Editor = 9,
Publisher = 10,
/// <summary>
/// Represents a character/person within the story
/// </summary>
Character = 11,
/// <summary>
/// The Translator
/// </summary>
Translator = 12
/// <summary>
/// Another role, not covered by other types
/// </summary>
Other = 1,
/// <summary>
/// Author or Writer
/// </summary>
Writer = 3,
Penciller = 4,
Inker = 5,
Colorist = 6,
Letterer = 7,
CoverArtist = 8,
Editor = 9,
Publisher = 10,
/// <summary>
/// Represents a character/person within the story
/// </summary>
Character = 11,
/// <summary>
/// The Translator
/// </summary>
Translator = 12
}
}

View file

@ -1,14 +1,13 @@
using System.ComponentModel;
namespace API.Entities.Enums
namespace API.Entities.Enums;
public enum ReaderMode
{
public enum ReaderMode
{
[Description("Left and Right")]
LeftRight = 0,
[Description("Up and Down")]
UpDown = 1,
[Description("Webtoon")]
Webtoon = 2
}
[Description("Left and Right")]
LeftRight = 0,
[Description("Up and Down")]
UpDown = 1,
[Description("Webtoon")]
Webtoon = 2
}

View file

@ -1,8 +1,7 @@
namespace API.Entities.Enums
namespace API.Entities.Enums;
public enum ReadingDirection
{
public enum ReadingDirection
{
LeftToRight = 0,
RightToLeft = 1
}
}
LeftToRight = 0,
RightToLeft = 1
}

View file

@ -1,10 +1,9 @@
namespace API.Entities.Enums
namespace API.Entities.Enums;
public enum ScalingOption
{
public enum ScalingOption
{
FitToHeight = 0,
FitToWidth = 1,
Original = 2,
Automatic = 3
}
}
FitToHeight = 0,
FitToWidth = 1,
Original = 2,
Automatic = 3
}

View file

@ -1,100 +1,99 @@
using System.ComponentModel;
namespace API.Entities.Enums
namespace API.Entities.Enums;
public enum ServerSettingKey
{
public enum ServerSettingKey
{
/// <summary>
/// Cron format for how often full library scans are performed.
/// </summary>
[Description("TaskScan")]
TaskScan = 0,
/// <summary>
/// Where files are cached. Not currently used.
/// </summary>
[Description("CacheDirectory")]
CacheDirectory = 1,
/// <summary>
/// Cron format for how often backups are taken.
/// </summary>
[Description("TaskBackup")]
TaskBackup = 2,
/// <summary>
/// Logging level for Server. Not managed in DB. Managed in appsettings.json and synced to DB.
/// </summary>
[Description("LoggingLevel")]
LoggingLevel = 3,
/// <summary>
/// Port server listens on. Not managed in DB. Managed in appsettings.json and synced to DB.
/// </summary>
[Description("Port")]
Port = 4,
/// <summary>
/// Where the backups are stored.
/// </summary>
[Description("BackupDirectory")]
BackupDirectory = 5,
/// <summary>
/// Allow anonymous data to be reported to KavitaStats
/// </summary>
[Description("AllowStatCollection")]
AllowStatCollection = 6,
/// <summary>
/// Is OPDS enabled for the server
/// </summary>
[Description("EnableOpds")]
EnableOpds = 7,
/// <summary>
/// Is Authentication needed for non-admin accounts
/// </summary>
/// <remarks>Deprecated. This is no longer used v0.5.1+. Assume Authentication is always in effect</remarks>
[Description("EnableAuthentication")]
EnableAuthentication = 8,
/// <summary>
/// Base Url for the server. Not Implemented.
/// </summary>
[Description("BaseUrl")]
BaseUrl = 9,
/// <summary>
/// Represents this installation of Kavita. Is tied to Stat reporting but has no information about user or files.
/// </summary>
[Description("InstallId")]
InstallId = 10,
/// <summary>
/// Represents the version the software is running.
/// </summary>
/// <remarks>This will be updated on Startup to the latest release. Provides ability to detect if certain migrations need to be run.</remarks>
[Description("InstallVersion")]
InstallVersion = 11,
/// <summary>
/// Location of where bookmarks are stored
/// </summary>
[Description("BookmarkDirectory")]
BookmarkDirectory = 12,
/// <summary>
/// If SMTP is enabled on the server
/// </summary>
[Description("CustomEmailService")]
EmailServiceUrl = 13,
/// <summary>
/// If Kavita should save bookmarks as WebP images
/// </summary>
[Description("ConvertBookmarkToWebP")]
ConvertBookmarkToWebP = 14,
/// <summary>
/// If the Swagger UI Should be exposed. Does not require authentication, but does require a JWT.
/// </summary>
[Description("EnableSwaggerUi")]
EnableSwaggerUi = 15,
/// <summary>
/// Total Number of Backups to maintain before cleaning. Default 30, min 1.
/// </summary>
[Description("TotalBackups")]
TotalBackups = 16,
/// <summary>
/// If Kavita should watch the library folders and process changes
/// </summary>
[Description("EnableFolderWatching")]
EnableFolderWatching = 17,
}
/// <summary>
/// Cron format for how often full library scans are performed.
/// </summary>
[Description("TaskScan")]
TaskScan = 0,
/// <summary>
/// Where files are cached. Not currently used.
/// </summary>
[Description("CacheDirectory")]
CacheDirectory = 1,
/// <summary>
/// Cron format for how often backups are taken.
/// </summary>
[Description("TaskBackup")]
TaskBackup = 2,
/// <summary>
/// Logging level for Server. Not managed in DB. Managed in appsettings.json and synced to DB.
/// </summary>
[Description("LoggingLevel")]
LoggingLevel = 3,
/// <summary>
/// Port server listens on. Not managed in DB. Managed in appsettings.json and synced to DB.
/// </summary>
[Description("Port")]
Port = 4,
/// <summary>
/// Where the backups are stored.
/// </summary>
[Description("BackupDirectory")]
BackupDirectory = 5,
/// <summary>
/// Allow anonymous data to be reported to KavitaStats
/// </summary>
[Description("AllowStatCollection")]
AllowStatCollection = 6,
/// <summary>
/// Is OPDS enabled for the server
/// </summary>
[Description("EnableOpds")]
EnableOpds = 7,
/// <summary>
/// Is Authentication needed for non-admin accounts
/// </summary>
/// <remarks>Deprecated. This is no longer used v0.5.1+. Assume Authentication is always in effect</remarks>
[Description("EnableAuthentication")]
EnableAuthentication = 8,
/// <summary>
/// Base Url for the server. Not Implemented.
/// </summary>
[Description("BaseUrl")]
BaseUrl = 9,
/// <summary>
/// Represents this installation of Kavita. Is tied to Stat reporting but has no information about user or files.
/// </summary>
[Description("InstallId")]
InstallId = 10,
/// <summary>
/// Represents the version the software is running.
/// </summary>
/// <remarks>This will be updated on Startup to the latest release. Provides ability to detect if certain migrations need to be run.</remarks>
[Description("InstallVersion")]
InstallVersion = 11,
/// <summary>
/// Location of where bookmarks are stored
/// </summary>
[Description("BookmarkDirectory")]
BookmarkDirectory = 12,
/// <summary>
/// If SMTP is enabled on the server
/// </summary>
[Description("CustomEmailService")]
EmailServiceUrl = 13,
/// <summary>
/// If Kavita should save bookmarks as WebP images
/// </summary>
[Description("ConvertBookmarkToWebP")]
ConvertBookmarkToWebP = 14,
/// <summary>
/// If the Swagger UI Should be exposed. Does not require authentication, but does require a JWT.
/// </summary>
[Description("EnableSwaggerUi")]
EnableSwaggerUi = 15,
/// <summary>
/// Total Number of Backups to maintain before cleaning. Default 30, min 1.
/// </summary>
[Description("TotalBackups")]
TotalBackups = 16,
/// <summary>
/// If Kavita should watch the library folders and process changes
/// </summary>
[Description("EnableFolderWatching")]
EnableFolderWatching = 17,
}