Stop Logger being a singleton

This commit is contained in:
Andras Schmelczer 2025-02-22 15:11:59 +00:00
parent d965265709
commit 3471a9c498
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
12 changed files with 147 additions and 138 deletions

View file

@ -20,6 +20,7 @@ export class Database {
private lastSeenUpdateId: VaultUpdateId | undefined;
public constructor(
private readonly logger: Logger,
initialState: Partial<StoredDatabase> | undefined,
private readonly saveData: (data: unknown) => Promise<void>
) {
@ -32,10 +33,10 @@ export class Database {
this.documents.set(relativePath, metadata as DocumentMetadata);
}
}
Logger.getInstance().debug(`Loaded ${this.documents.size} documents`);
this.logger.debug(`Loaded ${this.documents.size} documents`);
this.lastSeenUpdateId = initialState.lastSeenUpdateId;
Logger.getInstance().debug(
this.logger.debug(
`Loaded last seen update id: ${this.lastSeenUpdateId}`
);
}

View file

@ -33,6 +33,7 @@ export class Settings {
) => void)[] = [];
public constructor(
private readonly logger: Logger,
initialState: Partial<SyncSettings> | undefined,
private readonly saveData: (data: unknown) => Promise<void>
) {
@ -41,7 +42,7 @@ export class Settings {
...(initialState ?? {})
};
Logger.getInstance().debug(
this.logger.debug(
`Loaded settings: ${JSON.stringify(this.settings, null, 2)}`
);
}
@ -70,7 +71,7 @@ export class Settings {
value: SyncSettings[T]
): Promise<void> {
const newSettings = { ...this.settings, [key]: value };
Logger.getInstance().debug(
this.logger.debug(
`Setting ${key} to ${value}, new settings: ${JSON.stringify(
newSettings,
null,