Skip to content

Commit

Permalink
small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
davemarco committed Oct 1, 2024
1 parent 114af1d commit a2814e4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
13 changes: 8 additions & 5 deletions new-log-viewer/src/services/decoders/JsonlDecoder/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {Dayjs} from "dayjs";

import {Nullable} from "../../../typings/common";
import {
Decoder,
Expand All @@ -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";
Expand Down Expand Up @@ -91,7 +92,7 @@ class JsonlDecoder implements Decoder {
endIdx: number,
useFilter: boolean,
): Nullable<DecodeResultType[]> {
if (null === this.#filteredLogEventMap && useFilter) {
if (useFilter && null === this.#filteredLogEventMap) {
return null;
}

Expand Down Expand Up @@ -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;
}

/**
Expand Down
1 change: 1 addition & 0 deletions new-log-viewer/src/typings/formatters.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {JsonLogEvent} from "./logs";


/**
* Options for the LogbackFormatter.
*
Expand Down
11 changes: 5 additions & 6 deletions new-log-viewer/src/typings/logs.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -28,7 +26,8 @@ interface JsonLogEvent {

export type {
JsonLogEvent,
LogLevelFilter};
LogLevelFilter,
};
export {
INVALID_TIMESTAMP_VALUE,
LOG_LEVEL,
Expand Down

0 comments on commit a2814e4

Please sign in to comment.