Skip to content

Commit

Permalink
address suggested changes in pr
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry8192 committed Oct 7, 2024
1 parent 5bf7df1 commit 9a3cca9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions new-log-viewer/src/services/LogFileManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import ClpIrDecoder from "./decoders/ClpIrDecoder";
import JsonlDecoder from "./decoders/JsonlDecoder";


const SEARCH_CHUNK_SIZE = 1000;
const SEARCH_CHUNK_SIZE = 10000;

/**
* Loads a file from a given source.
Expand Down Expand Up @@ -297,7 +297,7 @@ class LogFileManager {
for (let eventIdx = beginSearchIdx; eventIdx < endSearchIdx; eventIdx++) {
const contentString = this.#decoder.decode(eventIdx, eventIdx + 1)?.[0]?.[0] || "";
const match = contentString.match(searchRegex);
if (match && match.index) {
if (match && "number" === typeof match.index) {
const logEventNum = eventIdx + 1;
const pageNum = Math.ceil(logEventNum / this.#pageSize);
if (!results[pageNum]) {
Expand Down
7 changes: 7 additions & 0 deletions new-log-viewer/src/services/MainWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ onmessage = async (ev: MessageEvent<MainWorkerReqMessage>) => {
if (null === LOG_FILE_MANAGER) {
throw new Error("Log file manager hasn't been initialized");
}
if (
"string" !== typeof args.searchString ||
"boolean" !== typeof args.isRegex ||
"boolean" !== typeof args.isCaseSensitive
) {
throw new Error("Invalid arguments for QUERY_LOG");
}
LOG_FILE_MANAGER.startQuery(
args.searchString,
args.isRegex,
Expand Down
6 changes: 3 additions & 3 deletions new-log-viewer/src/typings/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ type WorkerReqMap = {
searchString: string,
isRegex: boolean,
isCaseSensitive: boolean,
}
},
};

type ChunkResultType = {
Expand All @@ -90,12 +90,12 @@ type WorkerRespMap = {
},
[WORKER_RESP_CODE.NOTIFICATION]: {
logLevel: LOG_LEVEL,
message: string
message: string,
},
[WORKER_RESP_CODE.PAGE_DATA]: {
logs: string,
beginLineNumToLogEventNum: BeginLineNumToLogEventNumMap,
cursorLineNum: number
cursorLineNum: number,
},
[WORKER_RESP_CODE.CHUNK_RESULT]: ChunkResults,
};
Expand Down

0 comments on commit 9a3cca9

Please sign in to comment.