diff --git a/src/backend/middlewares/GalleryMWs.ts b/src/backend/middlewares/GalleryMWs.ts index 0b7dc1ec..da28a013 100644 --- a/src/backend/middlewares/GalleryMWs.ts +++ b/src/backend/middlewares/GalleryMWs.ts @@ -17,7 +17,6 @@ import {LocationLookupException} from '../exceptions/LocationLookupException'; import {SupportedFormats} from '../../common/SupportedFormats'; import {ServerTime} from './ServerTimingMWs'; import {SortByTypes} from '../../common/entities/SortingMethods'; -import {Logger} from '../Logger'; export class GalleryMWs { @ServerTime('1.db', 'List Directory') @@ -110,7 +109,7 @@ export class GalleryMWs { }); res.on('close', () => { - Logger.info('zip ' + archive.pointer() + ' bytes'); + console.log('zip ' + archive.pointer() + ' bytes'); }); archive.on('error', (err: Error) => { diff --git a/src/backend/middlewares/RenderingMWs.ts b/src/backend/middlewares/RenderingMWs.ts index 51d7292a..bb4ca0c1 100644 --- a/src/backend/middlewares/RenderingMWs.ts +++ b/src/backend/middlewares/RenderingMWs.ts @@ -132,13 +132,11 @@ export class RenderingMWs { ): void { if (err instanceof ErrorDTO) { if (err.details) { - const logFn = Logger.logLevelForError(err.code) - + LoggerRouter.log(logFn, req, res); // use separate rendering for detailsStr const d = err.detailsStr; delete err.detailsStr; - logFn('Handled error:\n', err); - LoggerRouter.log(logFn, req, res); + console.log(err); err.detailsStr = d; delete err.details; // do not send back error object to the client side diff --git a/src/backend/model/database/GalleryManager.ts b/src/backend/model/database/GalleryManager.ts index 06995371..7d551e1e 100644 --- a/src/backend/model/database/GalleryManager.ts +++ b/src/backend/model/database/GalleryManager.ts @@ -123,7 +123,7 @@ export class GalleryManager { ); ObjectManagers.getInstance() .IndexingManager.indexDirectory(relativeDirectoryName) - .catch(Logger.error); + .catch(console.error); } return await this.getParentDirFromId(connection, dir.id); } diff --git a/src/backend/model/database/IndexingManager.ts b/src/backend/model/database/IndexingManager.ts index fd09e679..a07bd083 100644 --- a/src/backend/model/database/IndexingManager.ts +++ b/src/backend/model/database/IndexingManager.ts @@ -100,13 +100,13 @@ export class IndexingManager { resolve(dirClone); // save directory to DB - this.queueForSave(scannedDirectory).catch(Logger.error); + this.queueForSave(scannedDirectory).catch(console.error); } catch (error) { NotificationManager.warning( 'Unknown indexing error for: ' + relativeDirectoryName, error.toString() ); - Logger.error(error); + console.error(error); return reject(error); } }); diff --git a/src/backend/model/database/SQLConnection.ts b/src/backend/model/database/SQLConnection.ts index 047ef7a3..07eb2ec9 100644 --- a/src/backend/model/database/SQLConnection.ts +++ b/src/backend/model/database/SQLConnection.ts @@ -155,7 +155,8 @@ export class SQLConnection { this.connection = null; } } catch (err) { - Logger.error('Error during closing sql db:\n', err); + console.error('Error during closing sql db:'); + console.error(err); } } diff --git a/src/backend/model/extension/ExtensionConfigWrapper.ts b/src/backend/model/extension/ExtensionConfigWrapper.ts index 5f5f248a..eaa7270f 100644 --- a/src/backend/model/extension/ExtensionConfigWrapper.ts +++ b/src/backend/model/extension/ExtensionConfigWrapper.ts @@ -3,7 +3,7 @@ import {PrivateConfigClass} from '../../../common/config/private/PrivateConfigCl import {ConfigClassBuilder} from 'typeconfig/node'; import {ExtensionConfigTemplateLoader} from './ExtensionConfigTemplateLoader'; import {NotificationManager} from '../NotifocationManager'; -import {Logger} from '../../Logger'; + const LOG_TAG = '[ExtensionConfigWrapper]'; @@ -19,9 +19,10 @@ export class ExtensionConfigWrapper { await pc.load(); // loading the basic configs, but we do not know the extension config hierarchy yet } catch (e) { - Logger.error(LOG_TAG, 'Error during loading config. Reverting to defaults.\n', e); + console.error(LOG_TAG, 'Error during loading config. Reverting to defaults.'); + console.error(e); if (showDetailedError) { - Logger.error(LOG_TAG, 'This is most likely due to: 1) you added a bad configuration in the server.json OR 2) The configuration changed in the latest release.'); + console.error(LOG_TAG, 'This is most likely due to: 1) you added a bad configuration in the server.json OR 2) The configuration changed in the latest release.'); NotificationManager.error('Can\'t load config. Reverting to default. This is most likely due to: 1) you added a bad configuration in the server.json OR 2) The configuration changed in the latest release.', (e.toString ? e.toString() : JSON.stringify(e))); } } @@ -36,9 +37,10 @@ export class ExtensionConfigWrapper { pc.loadSync(); // loading the basic configs, but we do not know the extension config hierarchy yet } catch (e) { - Logger.error(LOG_TAG, 'Error during loading config. Reverting to defaults.\n', e); + console.error(LOG_TAG, 'Error during loading config. Reverting to defaults.'); + console.error(e); if (showDetailedError) { - Logger.error(LOG_TAG, 'This is most likely due to: 1) you added a bad configuration in the server.json OR 2) The configuration changed in the latest release.'); + console.error(LOG_TAG, 'This is most likely due to: 1) you added a bad configuration in the server.json OR 2) The configuration changed in the latest release.'); NotificationManager.error('Ca\'nt load config. Reverting to default. This is most likely due to: 1) you added a bad configuration in the server.json OR 2) The configuration changed in the latest release.', (e.toString ? e.toString() : JSON.stringify(e))); } } diff --git a/src/backend/model/fileaccess/DiskManager.ts b/src/backend/model/fileaccess/DiskManager.ts index 5efaf424..e07ff2e3 100644 --- a/src/backend/model/fileaccess/DiskManager.ts +++ b/src/backend/model/fileaccess/DiskManager.ts @@ -179,7 +179,7 @@ export class DiskManager { 'Unknown directory reading error, skipping: ' + path.join(relativeDirectoryName, file), err.toString() ); - Logger.error(err); + console.error(err); } } else if (PhotoProcessing.isPhoto(fullFilePath)) { try { @@ -218,7 +218,7 @@ export class DiskManager { ', reason: ' + err.toString() ); - Logger.error(err); + console.error(err); } } else if (VideoProcessing.isVideo(fullFilePath)) { try { diff --git a/src/backend/model/fileaccess/MetadataLoader.ts b/src/backend/model/fileaccess/MetadataLoader.ts index 84ffa2be..5a61af21 100644 --- a/src/backend/model/fileaccess/MetadataLoader.ts +++ b/src/backend/model/fileaccess/MetadataLoader.ts @@ -41,7 +41,7 @@ export class MetadataLoader { metadata.fileSize = stat.size; metadata.creationDate = stat.mtime.getTime(); //Default date is file system time of last modification } catch (err) { - Logger.info(err); + console.log(err); // ignoring errors } try { @@ -214,7 +214,8 @@ export class MetadataLoader { try { await fileHandle.read(data, 0, bufferSize, 0); } catch (err) { - Logger.error(LOG_TAG, 'Error during reading photo: ' + fullPath + '\n', err); + Logger.error(LOG_TAG, 'Error during reading photo: ' + fullPath); + console.error(err); return MetadataLoader.EMPTY_METADATA; } finally { await fileHandle.close(); @@ -294,11 +295,13 @@ export class MetadataLoader { metadata.creationDate = 0; } } catch (err) { - Logger.error(LOG_TAG, 'Error during reading photo: ' + fullPath + '\n', err); + Logger.error(LOG_TAG, 'Error during reading photo: ' + fullPath); + console.error(err); return MetadataLoader.EMPTY_METADATA; } } catch (err) { - Logger.error(LOG_TAG, 'Error during reading photo: ' + fullPath + '\n', err); + Logger.error(LOG_TAG, 'Error during reading photo: ' + fullPath); + console.error(err); return MetadataLoader.EMPTY_METADATA; } return metadata; diff --git a/src/backend/model/fileaccess/TaskExecuter.ts b/src/backend/model/fileaccess/TaskExecuter.ts index 33ee75f3..4e203f03 100644 --- a/src/backend/model/fileaccess/TaskExecuter.ts +++ b/src/backend/model/fileaccess/TaskExecuter.ts @@ -1,6 +1,5 @@ import {TaskQue} from './TaskQue'; import {EventLoopHandler} from '../EventLoopHandler'; -import { Logger } from '../../Logger'; export interface ITaskExecuter { execute(input: I): Promise; @@ -31,7 +30,7 @@ export class TaskExecuter implements ITaskExecuter { execute(input: I): Promise { const promise = this.taskQue.add(input).promise.obj; - this.run().catch(Logger.error); + this.run().catch(console.error); return promise; } } diff --git a/src/backend/model/jobs/JobProgressManager.ts b/src/backend/model/jobs/JobProgressManager.ts index 4c637a2d..a1c46426 100644 --- a/src/backend/model/jobs/JobProgressManager.ts +++ b/src/backend/model/jobs/JobProgressManager.ts @@ -3,7 +3,6 @@ import * as path from 'path'; import {ProjectPath} from '../../ProjectPath'; import {Config} from '../../../common/config/private/Config'; import {JobProgressDTO, JobProgressStates,} from '../../../common/entities/job/JobProgressDTO'; -import { Logger } from '../../Logger'; export class JobProgressManager { private static readonly VERSION = 3; @@ -21,7 +20,7 @@ export class JobProgressManager { constructor() { this.dbPath = path.join(ProjectPath.DBFolder, 'jobs.db'); - this.loadDB().catch(Logger.error); + this.loadDB().catch(console.error); } get Progresses(): { [key: string]: JobProgressDTO } { @@ -90,7 +89,7 @@ export class JobProgressManager { return; } this.timer = setTimeout(async (): Promise => { - this.saveDB().catch(Logger.error); + this.saveDB().catch(console.error); this.timer = null; }, 5000); } diff --git a/src/backend/model/jobs/jobs/IndexingJob.ts b/src/backend/model/jobs/jobs/IndexingJob.ts index b85beb40..65973e85 100644 --- a/src/backend/model/jobs/jobs/IndexingJob.ts +++ b/src/backend/model/jobs/jobs/IndexingJob.ts @@ -93,7 +93,8 @@ export class IndexingJob< } catch (e) { this.Progress.log('Skipping. Indexing failed for: ' + directory); this.Progress.Skipped++; - Logger.warn(LOG_TAG, 'Skipping. Indexing failed for: ' + directory, + '\n', e); + Logger.warn(LOG_TAG, 'Skipping. Indexing failed for: ' + directory); + console.error(e); } if (this.Progress.State !== JobProgressStates.running) { return false; diff --git a/src/backend/model/jobs/jobs/Job.ts b/src/backend/model/jobs/jobs/Job.ts index ddf7c3f3..36a7a0cb 100644 --- a/src/backend/model/jobs/jobs/Job.ts +++ b/src/backend/model/jobs/jobs/Job.ts @@ -71,7 +71,7 @@ export abstract class Job = Record((resolve): void => { this.prResolve = resolve; }); - this.init().catch(Logger.error); + this.init().catch(console.error); this.run(); if (!this.IsInstant) { // if instant, wait for execution, otherwise, return right away diff --git a/src/backend/model/messenger/StdoutMessenger.ts b/src/backend/model/messenger/StdoutMessenger.ts index 86cabbb6..1edbf20a 100644 --- a/src/backend/model/messenger/StdoutMessenger.ts +++ b/src/backend/model/messenger/StdoutMessenger.ts @@ -1,7 +1,6 @@ import {MediaDTOWithThPath, Messenger} from './Messenger'; import {DynamicConfig} from '../../../common/entities/DynamicConfig'; import {DefaultMessengers} from '../../../common/entities/job/JobDTO'; -import { Logger } from '../../Logger'; export class StdoutMessenger extends Messenger { public readonly Name = DefaultMessengers[DefaultMessengers.Stdout]; @@ -13,6 +12,6 @@ export class StdoutMessenger extends Messenger { protected async sendMedia(config: never, media: MediaDTOWithThPath[]) { - Logger.info(media.map(m => m.thumbnailPath)); + console.log(media.map(m => m.thumbnailPath)); } } diff --git a/src/backend/routes/ErrorRouter.ts b/src/backend/routes/ErrorRouter.ts index 6fc76e96..3507e631 100644 --- a/src/backend/routes/ErrorRouter.ts +++ b/src/backend/routes/ErrorRouter.ts @@ -38,7 +38,8 @@ export class ErrorRouter { } // Flush out the stack to the console - Logger.error('Unexpected error:\n', err); + Logger.error('Unexpected error:'); + console.error(err); return next( new ErrorDTO( ErrorCodes.SERVER_ERROR, diff --git a/src/backend/server.ts b/src/backend/server.ts index 9c0a9213..382330e6 100644 --- a/src/backend/server.ts +++ b/src/backend/server.ts @@ -51,7 +51,7 @@ export class Server { 'Running in DEBUG mode, set env variable NODE_ENV=production to disable ' ); } - this.init(listen).catch(Logger.error); + this.init(listen).catch(console.error); } get Server(): HttpServer {