1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2025-01-10 04:07:35 +02:00

Revert "Always use Logger class and try to log once per event"

This reverts commit a57a717717a676555b4e28d5746828477c2f9811.
This commit is contained in:
sarayourfriend 2024-03-31 09:28:04 +11:00
parent b0c2f8da04
commit fcdb2f2938
No known key found for this signature in database
15 changed files with 34 additions and 32 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,5 @@
import {TaskQue} from './TaskQue';
import {EventLoopHandler} from '../EventLoopHandler';
import { Logger } from '../../Logger';
export interface ITaskExecuter<I, O> {
execute(input: I): Promise<O>;
@ -31,7 +30,7 @@ export class TaskExecuter<I, O> implements ITaskExecuter<I, O> {
execute(input: I): Promise<O> {
const promise = this.taskQue.add(input).promise.obj;
this.run().catch(Logger.error);
this.run().catch(console.error);
return promise;
}
}

View File

@ -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<void> => {
this.saveDB().catch(Logger.error);
this.saveDB().catch(console.error);
this.timer = null;
}, 5000);
}

View File

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

View File

@ -71,7 +71,7 @@ export abstract class Job<T extends Record<string, unknown> = Record<string, unk
const pr = new Promise<void>((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

View File

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

View File

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

View File

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