1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-12-23 01:27:14 +02:00

Adding debug log to diagnostics #632

This commit is contained in:
Patrik J. Braun 2023-03-12 11:42:41 +01:00
parent 6134a7d35e
commit c3e11bfb90

View File

@ -34,6 +34,7 @@ export class ConfigDiagnostics {
albumConfig: ClientAlbumConfig, albumConfig: ClientAlbumConfig,
original: PrivateConfigClass original: PrivateConfigClass
): void { ): void {
Logger.debug(LOG_TAG, 'Testing album config');
// nothing to check // nothing to check
} }
@ -52,6 +53,7 @@ export class ConfigDiagnostics {
static async testDatabase( static async testDatabase(
databaseConfig: ServerDataBaseConfig databaseConfig: ServerDataBaseConfig
): Promise<void> { ): Promise<void> {
Logger.debug(LOG_TAG, 'Testing database config');
await SQLConnection.tryConnection(databaseConfig); await SQLConnection.tryConnection(databaseConfig);
if (databaseConfig.type === DatabaseType.sqlite) { if (databaseConfig.type === DatabaseType.sqlite) {
try { try {
@ -71,6 +73,7 @@ export class ConfigDiagnostics {
metaFileConfig: ClientMetaFileConfig, metaFileConfig: ClientMetaFileConfig,
config: PrivateConfigClass config: PrivateConfigClass
): Promise<void> { ): Promise<void> {
Logger.debug(LOG_TAG, 'Testing meta file config');
if (metaFileConfig.gpx === true && config.Map.enabled === false) { if (metaFileConfig.gpx === true && config.Map.enabled === false) {
throw new Error('*.gpx meta files are not supported without MAP'); throw new Error('*.gpx meta files are not supported without MAP');
} }
@ -78,6 +81,7 @@ export class ConfigDiagnostics {
static testVideoConfig(videoConfig: ServerVideoConfig, static testVideoConfig(videoConfig: ServerVideoConfig,
config: PrivateConfigClass): Promise<void> { config: PrivateConfigClass): Promise<void> {
Logger.debug(LOG_TAG, 'Testing video config with ffmpeg test');
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
try { try {
@ -120,16 +124,19 @@ export class ConfigDiagnostics {
static async testSharp(): Promise<void> { static async testSharp(): Promise<void> {
Logger.debug(LOG_TAG, 'Testing sharp package');
// eslint-disable-next-line @typescript-eslint/no-var-requires // eslint-disable-next-line @typescript-eslint/no-var-requires
const sharp = require('sharp'); const sharp = require('sharp');
sharp(); sharp();
} }
static async testTempFolder(folder: string): Promise<void> { static async testTempFolder(folder: string): Promise<void> {
Logger.debug(LOG_TAG, 'Testing temp folder');
await this.checkReadWritePermission(folder); await this.checkReadWritePermission(folder);
} }
static testImageFolder(folder: string): Promise<void> { static testImageFolder(folder: string): Promise<void> {
Logger.debug(LOG_TAG, 'Testing images folder');
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (!fs.existsSync(folder)) { if (!fs.existsSync(folder)) {
reject('Images folder not exists: \'' + folder + '\''); reject('Images folder not exists: \'' + folder + '\'');
@ -150,6 +157,7 @@ export class ConfigDiagnostics {
static async testThumbnailConfig( static async testThumbnailConfig(
thumbnailConfig: ServerThumbnailConfig thumbnailConfig: ServerThumbnailConfig
): Promise<void> { ): Promise<void> {
Logger.debug(LOG_TAG, 'Testing thumbnail config');
if (thumbnailConfig.personFaceMargin < 0 || thumbnailConfig.personFaceMargin > 1) { if (thumbnailConfig.personFaceMargin < 0 || thumbnailConfig.personFaceMargin > 1) {
@ -176,6 +184,7 @@ export class ConfigDiagnostics {
task: ServerJobConfig, task: ServerJobConfig,
config: PrivateConfigClass config: PrivateConfigClass
): Promise<void> { ): Promise<void> {
Logger.debug(LOG_TAG, 'Testing tasks config');
return; return;
} }
@ -183,6 +192,7 @@ export class ConfigDiagnostics {
faces: ClientFacesConfig, faces: ClientFacesConfig,
config: PrivateConfigClass config: PrivateConfigClass
): Promise<void> { ): Promise<void> {
Logger.debug(LOG_TAG, 'Testing faces config');
if (faces.enabled === true) { if (faces.enabled === true) {
if (config.Search.enabled === false) { if (config.Search.enabled === false) {
throw new Error('Faces support needs enabled search'); throw new Error('Faces support needs enabled search');
@ -194,6 +204,7 @@ export class ConfigDiagnostics {
search: ClientSearchConfig, search: ClientSearchConfig,
config: PrivateConfigClass config: PrivateConfigClass
): Promise<void> { ): Promise<void> {
Logger.debug(LOG_TAG, 'Testing search config');
//nothing to check //nothing to check
} }
@ -201,6 +212,7 @@ export class ConfigDiagnostics {
sharing: ClientSharingConfig, sharing: ClientSharingConfig,
config: PrivateConfigClass config: PrivateConfigClass
): Promise<void> { ): Promise<void> {
Logger.debug(LOG_TAG, 'Testing sharing config');
if ( if (
sharing.enabled === true && sharing.enabled === true &&
config.Users.authenticationRequired === false config.Users.authenticationRequired === false
@ -213,10 +225,12 @@ export class ConfigDiagnostics {
sharing: ClientRandomPhotoConfig, sharing: ClientRandomPhotoConfig,
config: PrivateConfigClass config: PrivateConfigClass
): Promise<void> { ): Promise<void> {
Logger.debug(LOG_TAG, 'Testing random photo config');
//nothing to check //nothing to check
} }
static async testMapConfig(map: ClientMapConfig): Promise<void> { static async testMapConfig(map: ClientMapConfig): Promise<void> {
Logger.debug(LOG_TAG, 'Testing map config');
if (map.enabled === false) { if (map.enabled === false) {
return; return;
} }
@ -242,6 +256,7 @@ export class ConfigDiagnostics {
} }
static async testPreviewConfig(settings: ServerPreviewConfig): Promise<void> { static async testPreviewConfig(settings: ServerPreviewConfig): Promise<void> {
Logger.debug(LOG_TAG, 'Testing preview config');
const sp = new SearchQueryParser(); const sp = new SearchQueryParser();
if ( if (
!Utils.equalsFilter( !Utils.equalsFilter(