Export consts

This commit is contained in:
Andras Schmelczer 2025-11-22 20:31:27 +00:00
parent c798d96009
commit d4b68154df
4 changed files with 18 additions and 10 deletions

View file

@ -1,3 +1,5 @@
import { MAX_LOG_MESSAGE_COUNT } from "../consts";
export enum LogLevel {
DEBUG = "DEBUG",
INFO = "INFO",
@ -21,7 +23,6 @@ export class LogLine {
}
export class Logger {
private static readonly MAX_MESSAGES = 100000;
private readonly messages: LogLine[] = [];
private readonly onMessageListeners: ((message: LogLine) => unknown)[] = [];
@ -68,7 +69,7 @@ export class Logger {
const logLine = new LogLine(level, message);
this.messages.push(logLine);
while (this.messages.length > Logger.MAX_MESSAGES) {
while (this.messages.length > MAX_LOG_MESSAGE_COUNT) {
this.messages.shift();
}

View file

@ -1,3 +1,7 @@
import {
MAX_HISTORY_ENTRY_COUNT,
TIMEOUT_FOR_MERGING_HISTORY_ENTRIES_IN_SECONDS
} from "../consts";
import type { RelativePath } from "../persistence/database";
import type { Logger } from "./logger";
@ -64,9 +68,6 @@ export interface HistoryStats {
}
export class SyncHistory {
private static readonly MAX_ENTRIES = 5000;
private static readonly TIMEOUT_FOR_MERGING_ENTRIES_IN_SECONDS = 60;
private _entries: HistoryEntry[] = [];
private readonly syncHistoryUpdateListeners: ((
@ -104,7 +105,7 @@ export class SyncHistory {
// Insert the entry at the beginning
this._entries.unshift(historyEntry);
if (this._entries.length > SyncHistory.MAX_ENTRIES) {
if (this._entries.length > MAX_HISTORY_ENTRY_COUNT) {
this._entries.pop();
}
@ -145,7 +146,7 @@ export class SyncHistory {
candidate !== undefined &&
(this._entries[0] === candidate ||
candidate.timestamp.getTime() +
SyncHistory.TIMEOUT_FOR_MERGING_ENTRIES_IN_SECONDS * 1000 >
TIMEOUT_FOR_MERGING_HISTORY_ENTRIES_IN_SECONDS * 1000 >
entry.timestamp.getTime())
) {
return candidate;