From a2814e42dc3ecd1bf7946281162bca81516c03cc Mon Sep 17 00:00:00 2001 From: Dave Marco Date: Tue, 1 Oct 2024 00:34:40 +0000 Subject: [PATCH] small changes --- .../src/services/decoders/JsonlDecoder/index.ts | 13 ++++++++----- new-log-viewer/src/typings/formatters.ts | 1 + new-log-viewer/src/typings/logs.ts | 11 +++++------ 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/new-log-viewer/src/services/decoders/JsonlDecoder/index.ts b/new-log-viewer/src/services/decoders/JsonlDecoder/index.ts index 13022be4..b597c98c 100644 --- a/new-log-viewer/src/services/decoders/JsonlDecoder/index.ts +++ b/new-log-viewer/src/services/decoders/JsonlDecoder/index.ts @@ -1,3 +1,5 @@ +import {Dayjs} from "dayjs"; + import {Nullable} from "../../../typings/common"; import { Decoder, @@ -6,12 +8,11 @@ import { JsonlDecoderOptionsType, LogEventCount, } from "../../../typings/decoders"; -import {Dayjs} from "dayjs"; import {Formatter} from "../../../typings/formatters"; import {JsonValue} from "../../../typings/js"; import { - JsonLogEvent, INVALID_TIMESTAMP_VALUE, + JsonLogEvent, LOG_LEVEL, LogLevelFilter, } from "../../../typings/logs"; @@ -91,7 +92,7 @@ class JsonlDecoder implements Decoder { endIdx: number, useFilter: boolean, ): Nullable { - if (null === this.#filteredLogEventMap && useFilter) { + if (useFilter && null === this.#filteredLogEventMap) { return null; } @@ -190,15 +191,17 @@ class JsonlDecoder implements Decoder { #filterLogEvents (logLevelFilter: LogLevelFilter) { if (null === logLevelFilter) { this.#filteredLogEventMap = null; + return; } - this.#filteredLogEventMap = []; + const filteredLogEventMap: number[] = []; this.#logEvents.forEach((logEvent, index) => { if (logLevelFilter.includes(logEvent.level)) { - (this.#filteredLogEventMap as number[]).push(index); + filteredLogEventMap.push(index); } }); + this.#filteredLogEventMap = filteredLogEventMap; } /** diff --git a/new-log-viewer/src/typings/formatters.ts b/new-log-viewer/src/typings/formatters.ts index 6ed90509..f426af58 100644 --- a/new-log-viewer/src/typings/formatters.ts +++ b/new-log-viewer/src/typings/formatters.ts @@ -1,5 +1,6 @@ import {JsonLogEvent} from "./logs"; + /** * Options for the LogbackFormatter. * diff --git a/new-log-viewer/src/typings/logs.ts b/new-log-viewer/src/typings/logs.ts index 3c89e7c5..17b381b7 100644 --- a/new-log-viewer/src/typings/logs.ts +++ b/new-log-viewer/src/typings/logs.ts @@ -1,10 +1,8 @@ -import {Nullable} from "./common"; - import {Dayjs} from "dayjs"; -import { - JsonObject, -} from "./js"; +import {Nullable} from "./common"; +import {JsonObject} from "./js"; + enum LOG_LEVEL { NONE = 0, @@ -28,7 +26,8 @@ interface JsonLogEvent { export type { JsonLogEvent, - LogLevelFilter}; + LogLevelFilter, +}; export { INVALID_TIMESTAMP_VALUE, LOG_LEVEL,