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:
parent
b0c2f8da04
commit
fcdb2f2938
@ -17,7 +17,6 @@ import {LocationLookupException} from '../exceptions/LocationLookupException';
|
|||||||
import {SupportedFormats} from '../../common/SupportedFormats';
|
import {SupportedFormats} from '../../common/SupportedFormats';
|
||||||
import {ServerTime} from './ServerTimingMWs';
|
import {ServerTime} from './ServerTimingMWs';
|
||||||
import {SortByTypes} from '../../common/entities/SortingMethods';
|
import {SortByTypes} from '../../common/entities/SortingMethods';
|
||||||
import {Logger} from '../Logger';
|
|
||||||
|
|
||||||
export class GalleryMWs {
|
export class GalleryMWs {
|
||||||
@ServerTime('1.db', 'List Directory')
|
@ServerTime('1.db', 'List Directory')
|
||||||
@ -110,7 +109,7 @@ export class GalleryMWs {
|
|||||||
});
|
});
|
||||||
|
|
||||||
res.on('close', () => {
|
res.on('close', () => {
|
||||||
Logger.info('zip ' + archive.pointer() + ' bytes');
|
console.log('zip ' + archive.pointer() + ' bytes');
|
||||||
});
|
});
|
||||||
|
|
||||||
archive.on('error', (err: Error) => {
|
archive.on('error', (err: Error) => {
|
||||||
|
@ -132,13 +132,11 @@ export class RenderingMWs {
|
|||||||
): void {
|
): void {
|
||||||
if (err instanceof ErrorDTO) {
|
if (err instanceof ErrorDTO) {
|
||||||
if (err.details) {
|
if (err.details) {
|
||||||
const logFn = Logger.logLevelForError(err.code)
|
LoggerRouter.log(logFn, req, res);
|
||||||
|
|
||||||
// use separate rendering for detailsStr
|
// use separate rendering for detailsStr
|
||||||
const d = err.detailsStr;
|
const d = err.detailsStr;
|
||||||
delete err.detailsStr;
|
delete err.detailsStr;
|
||||||
logFn('Handled error:\n', err);
|
console.log(err);
|
||||||
LoggerRouter.log(logFn, req, res);
|
|
||||||
err.detailsStr = d;
|
err.detailsStr = d;
|
||||||
delete err.details; // do not send back error object to the client side
|
delete err.details; // do not send back error object to the client side
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ export class GalleryManager {
|
|||||||
);
|
);
|
||||||
ObjectManagers.getInstance()
|
ObjectManagers.getInstance()
|
||||||
.IndexingManager.indexDirectory(relativeDirectoryName)
|
.IndexingManager.indexDirectory(relativeDirectoryName)
|
||||||
.catch(Logger.error);
|
.catch(console.error);
|
||||||
}
|
}
|
||||||
return await this.getParentDirFromId(connection, dir.id);
|
return await this.getParentDirFromId(connection, dir.id);
|
||||||
}
|
}
|
||||||
|
@ -100,13 +100,13 @@ export class IndexingManager {
|
|||||||
resolve(dirClone);
|
resolve(dirClone);
|
||||||
|
|
||||||
// save directory to DB
|
// save directory to DB
|
||||||
this.queueForSave(scannedDirectory).catch(Logger.error);
|
this.queueForSave(scannedDirectory).catch(console.error);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
NotificationManager.warning(
|
NotificationManager.warning(
|
||||||
'Unknown indexing error for: ' + relativeDirectoryName,
|
'Unknown indexing error for: ' + relativeDirectoryName,
|
||||||
error.toString()
|
error.toString()
|
||||||
);
|
);
|
||||||
Logger.error(error);
|
console.error(error);
|
||||||
return reject(error);
|
return reject(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -155,7 +155,8 @@ export class SQLConnection {
|
|||||||
this.connection = null;
|
this.connection = null;
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
Logger.error('Error during closing sql db:\n', err);
|
console.error('Error during closing sql db:');
|
||||||
|
console.error(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import {PrivateConfigClass} from '../../../common/config/private/PrivateConfigCl
|
|||||||
import {ConfigClassBuilder} from 'typeconfig/node';
|
import {ConfigClassBuilder} from 'typeconfig/node';
|
||||||
import {ExtensionConfigTemplateLoader} from './ExtensionConfigTemplateLoader';
|
import {ExtensionConfigTemplateLoader} from './ExtensionConfigTemplateLoader';
|
||||||
import {NotificationManager} from '../NotifocationManager';
|
import {NotificationManager} from '../NotifocationManager';
|
||||||
import {Logger} from '../../Logger';
|
|
||||||
|
|
||||||
const LOG_TAG = '[ExtensionConfigWrapper]';
|
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
|
await pc.load(); // loading the basic configs, but we do not know the extension config hierarchy yet
|
||||||
|
|
||||||
} catch (e) {
|
} 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) {
|
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)));
|
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
|
pc.loadSync(); // loading the basic configs, but we do not know the extension config hierarchy yet
|
||||||
|
|
||||||
} catch (e) {
|
} 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) {
|
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)));
|
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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ export class DiskManager {
|
|||||||
'Unknown directory reading error, skipping: ' + path.join(relativeDirectoryName, file),
|
'Unknown directory reading error, skipping: ' + path.join(relativeDirectoryName, file),
|
||||||
err.toString()
|
err.toString()
|
||||||
);
|
);
|
||||||
Logger.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
} else if (PhotoProcessing.isPhoto(fullFilePath)) {
|
} else if (PhotoProcessing.isPhoto(fullFilePath)) {
|
||||||
try {
|
try {
|
||||||
@ -218,7 +218,7 @@ export class DiskManager {
|
|||||||
', reason: ' +
|
', reason: ' +
|
||||||
err.toString()
|
err.toString()
|
||||||
);
|
);
|
||||||
Logger.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
} else if (VideoProcessing.isVideo(fullFilePath)) {
|
} else if (VideoProcessing.isVideo(fullFilePath)) {
|
||||||
try {
|
try {
|
||||||
|
@ -41,7 +41,7 @@ export class MetadataLoader {
|
|||||||
metadata.fileSize = stat.size;
|
metadata.fileSize = stat.size;
|
||||||
metadata.creationDate = stat.mtime.getTime(); //Default date is file system time of last modification
|
metadata.creationDate = stat.mtime.getTime(); //Default date is file system time of last modification
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
Logger.info(err);
|
console.log(err);
|
||||||
// ignoring errors
|
// ignoring errors
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -214,7 +214,8 @@ export class MetadataLoader {
|
|||||||
try {
|
try {
|
||||||
await fileHandle.read(data, 0, bufferSize, 0);
|
await fileHandle.read(data, 0, bufferSize, 0);
|
||||||
} catch (err) {
|
} 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 MetadataLoader.EMPTY_METADATA;
|
||||||
} finally {
|
} finally {
|
||||||
await fileHandle.close();
|
await fileHandle.close();
|
||||||
@ -294,11 +295,13 @@ export class MetadataLoader {
|
|||||||
metadata.creationDate = 0;
|
metadata.creationDate = 0;
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} 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 MetadataLoader.EMPTY_METADATA;
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} 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 MetadataLoader.EMPTY_METADATA;
|
||||||
}
|
}
|
||||||
return metadata;
|
return metadata;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import {TaskQue} from './TaskQue';
|
import {TaskQue} from './TaskQue';
|
||||||
import {EventLoopHandler} from '../EventLoopHandler';
|
import {EventLoopHandler} from '../EventLoopHandler';
|
||||||
import { Logger } from '../../Logger';
|
|
||||||
|
|
||||||
export interface ITaskExecuter<I, O> {
|
export interface ITaskExecuter<I, O> {
|
||||||
execute(input: I): Promise<O>;
|
execute(input: I): Promise<O>;
|
||||||
@ -31,7 +30,7 @@ export class TaskExecuter<I, O> implements ITaskExecuter<I, O> {
|
|||||||
|
|
||||||
execute(input: I): Promise<O> {
|
execute(input: I): Promise<O> {
|
||||||
const promise = this.taskQue.add(input).promise.obj;
|
const promise = this.taskQue.add(input).promise.obj;
|
||||||
this.run().catch(Logger.error);
|
this.run().catch(console.error);
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ import * as path from 'path';
|
|||||||
import {ProjectPath} from '../../ProjectPath';
|
import {ProjectPath} from '../../ProjectPath';
|
||||||
import {Config} from '../../../common/config/private/Config';
|
import {Config} from '../../../common/config/private/Config';
|
||||||
import {JobProgressDTO, JobProgressStates,} from '../../../common/entities/job/JobProgressDTO';
|
import {JobProgressDTO, JobProgressStates,} from '../../../common/entities/job/JobProgressDTO';
|
||||||
import { Logger } from '../../Logger';
|
|
||||||
|
|
||||||
export class JobProgressManager {
|
export class JobProgressManager {
|
||||||
private static readonly VERSION = 3;
|
private static readonly VERSION = 3;
|
||||||
@ -21,7 +20,7 @@ export class JobProgressManager {
|
|||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.dbPath = path.join(ProjectPath.DBFolder, 'jobs.db');
|
this.dbPath = path.join(ProjectPath.DBFolder, 'jobs.db');
|
||||||
this.loadDB().catch(Logger.error);
|
this.loadDB().catch(console.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
get Progresses(): { [key: string]: JobProgressDTO } {
|
get Progresses(): { [key: string]: JobProgressDTO } {
|
||||||
@ -90,7 +89,7 @@ export class JobProgressManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.timer = setTimeout(async (): Promise<void> => {
|
this.timer = setTimeout(async (): Promise<void> => {
|
||||||
this.saveDB().catch(Logger.error);
|
this.saveDB().catch(console.error);
|
||||||
this.timer = null;
|
this.timer = null;
|
||||||
}, 5000);
|
}, 5000);
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,8 @@ export class IndexingJob<
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.Progress.log('Skipping. Indexing failed for: ' + directory);
|
this.Progress.log('Skipping. Indexing failed for: ' + directory);
|
||||||
this.Progress.Skipped++;
|
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) {
|
if (this.Progress.State !== JobProgressStates.running) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -71,7 +71,7 @@ export abstract class Job<T extends Record<string, unknown> = Record<string, unk
|
|||||||
const pr = new Promise<void>((resolve): void => {
|
const pr = new Promise<void>((resolve): void => {
|
||||||
this.prResolve = resolve;
|
this.prResolve = resolve;
|
||||||
});
|
});
|
||||||
this.init().catch(Logger.error);
|
this.init().catch(console.error);
|
||||||
this.run();
|
this.run();
|
||||||
if (!this.IsInstant) {
|
if (!this.IsInstant) {
|
||||||
// if instant, wait for execution, otherwise, return right away
|
// if instant, wait for execution, otherwise, return right away
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import {MediaDTOWithThPath, Messenger} from './Messenger';
|
import {MediaDTOWithThPath, Messenger} from './Messenger';
|
||||||
import {DynamicConfig} from '../../../common/entities/DynamicConfig';
|
import {DynamicConfig} from '../../../common/entities/DynamicConfig';
|
||||||
import {DefaultMessengers} from '../../../common/entities/job/JobDTO';
|
import {DefaultMessengers} from '../../../common/entities/job/JobDTO';
|
||||||
import { Logger } from '../../Logger';
|
|
||||||
|
|
||||||
export class StdoutMessenger extends Messenger {
|
export class StdoutMessenger extends Messenger {
|
||||||
public readonly Name = DefaultMessengers[DefaultMessengers.Stdout];
|
public readonly Name = DefaultMessengers[DefaultMessengers.Stdout];
|
||||||
@ -13,6 +12,6 @@ export class StdoutMessenger extends Messenger {
|
|||||||
|
|
||||||
|
|
||||||
protected async sendMedia(config: never, media: MediaDTOWithThPath[]) {
|
protected async sendMedia(config: never, media: MediaDTOWithThPath[]) {
|
||||||
Logger.info(media.map(m => m.thumbnailPath));
|
console.log(media.map(m => m.thumbnailPath));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,8 @@ export class ErrorRouter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Flush out the stack to the console
|
// Flush out the stack to the console
|
||||||
Logger.error('Unexpected error:\n', err);
|
Logger.error('Unexpected error:');
|
||||||
|
console.error(err);
|
||||||
return next(
|
return next(
|
||||||
new ErrorDTO(
|
new ErrorDTO(
|
||||||
ErrorCodes.SERVER_ERROR,
|
ErrorCodes.SERVER_ERROR,
|
||||||
|
@ -51,7 +51,7 @@ export class Server {
|
|||||||
'Running in DEBUG mode, set env variable NODE_ENV=production to disable '
|
'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 {
|
get Server(): HttpServer {
|
||||||
|
Loading…
Reference in New Issue
Block a user