mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-01-07 08:13:12 +00:00
chore: add logging to LocalHistory for storage init
This commit is contained in:
parent
907572956b
commit
3e3c5111b7
@ -1,3 +1,4 @@
|
|||||||
|
import { Logger } from "@waku/utils";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
|
|
||||||
import { type ChannelId, ContentMessage, isContentMessage } from "./message.js";
|
import { type ChannelId, ContentMessage, isContentMessage } from "./message.js";
|
||||||
@ -53,6 +54,8 @@ export type MemLocalHistoryOptions = {
|
|||||||
maxSize?: number;
|
maxSize?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const log = new Logger("sds:local-history");
|
||||||
|
|
||||||
export class MemLocalHistory implements ILocalHistory {
|
export class MemLocalHistory implements ILocalHistory {
|
||||||
private items: ContentMessage[] = [];
|
private items: ContentMessage[] = [];
|
||||||
private readonly storage?: PersistentStorage;
|
private readonly storage?: PersistentStorage;
|
||||||
@ -70,10 +73,13 @@ export class MemLocalHistory implements ILocalHistory {
|
|||||||
this.maxSize = maxSize ?? DEFAULT_MAX_LENGTH;
|
this.maxSize = maxSize ?? DEFAULT_MAX_LENGTH;
|
||||||
if (storage instanceof PersistentStorage) {
|
if (storage instanceof PersistentStorage) {
|
||||||
this.storage = storage;
|
this.storage = storage;
|
||||||
|
log.info("Using explicit persistent storage");
|
||||||
} else if (typeof storage === "string") {
|
} else if (typeof storage === "string") {
|
||||||
this.storage = PersistentStorage.create(storage);
|
this.storage = PersistentStorage.create(storage);
|
||||||
|
log.info("Creating persistent storage for channel", storage);
|
||||||
} else {
|
} else {
|
||||||
this.storage = undefined;
|
this.storage = undefined;
|
||||||
|
log.info("Using in-memory storage");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.load();
|
this.load();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user