Skip to content

Commit 9fca680

Browse files
authored
Plain Text Logs Normalizer (#2)
* normalize non-json logs * add tests * update Readme.md
1 parent 88f40c4 commit 9fca680

File tree

12 files changed

+342
-193
lines changed

12 files changed

+342
-193
lines changed

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,28 @@ Analog is a powerful tool designed for analyzing and visualizing log files. It p
1010

1111
- **Filter by Timestamp**: Specify a start and end timestamp to narrow down your log analysis.
1212
- **Regex Search**: Perform regular expression searches to find specific log entries.
13+
- **Search Combinations**: Perform normal searches with advanced combination of `Contains/Not Contains` and `AND/OR` operators.
1314
- **Top Logs**: Select entries in the Top Logs to view all the related logs together.
1415
- **Errors Only**: Isolate and focus on error log entries.
1516

17+
- **Logs Context**: Even when a filter is applied, you can access the context around the current log entry.
18+
1619
- **Log File Comparison**:
20+
1721
- **Compare Two Log Files**: Compare two log files and see newly added or removed log entries.
22+
1823
- **Create and Download a Filtered Subset**: Define filtering criteria to extract a specific subset of logs. You can also compare two subsets of a single log file to track changes.
1924

2025
- **Time Jumps**: Navigate through log data in subsets repeating after every few minutes.
2126

22-
- **See Data for Specific Fields/Keys**: Easily access and view log entries based on specific fields.
23-
2427
- **Highlighted JSON Syntax**: Log entries with JSON data are automatically highlighted for improved readability.
2528

2629
- **Highlighted Errors**: Errors in log entries are highlighted, making them stand out for quick identification.
2730

28-
## Things to remember
31+
## Prerequisite
2932

30-
- Currently supports only `json` logs.
31-
- Ensure you have Python 3 installed on your system to simply run via executing the `analog.sh`.
32-
- Or you can use any server of your preference to run the `index.html`
33+
- Ensure you have Python 3 installed on your system then you can simply execute `analog.sh` to run the app.
34+
- Otherwise run the `index.html` manually on any server of your preference.
3335

3436
## Getting Started
3537

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"@suid/vite-plugin": "^0.1.4",
2323
"@vitest/coverage-v8": "^0.34.6",
2424
"jsdom": "^22.1.0",
25-
"solid-devtools": "^0.27.7",
25+
"solid-devtools": "^0.28.1",
2626
"typescript": "^5.2.2",
2727
"vite": "^4.4.9",
2828
"vite-plugin-solid": "^2.7.0",

pnpm-lock.yaml

Lines changed: 32 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/models/logData.test.ts

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import stringsUtils from "../utils/strings";
2-
import LogData, { GroupedMsg } from "./logData";
1+
import stringsUtils from "@al/utils/strings";
2+
import LogData, { GroupedMsg, JSONLog, LogsGenerator } from "./logData";
33

44
describe("isErrorLog", () => {
55
it.each([
@@ -40,18 +40,18 @@ describe("isErrorLog", () => {
4040
describe("init", () => {
4141
const cutOffLen = LogData["msgCutOffLen"];
4242

43-
it("init", async () => {
43+
it("init", () => {
4444
const log0 = {
4545
[LogData.logKeys.error]: "some error",
4646
[LogData.logKeys.msg]: "has errors",
4747
parentKey1: "k1",
48-
};
48+
} as JSONLog;
4949
const log0String = getJSONString(log0);
5050
const log1 = {
5151
[LogData.logKeys.level]: "error",
5252
[LogData.logKeys.msg]: "dbg msg",
5353
parentKey1: "k1",
54-
};
54+
} as JSONLog;
5555
const log1String = getJSONString(log1);
5656
const log2 = {
5757
[LogData.logKeys.level]: "info",
@@ -60,23 +60,23 @@ describe("init", () => {
6060
childKey1: 11,
6161
childKey2: 12,
6262
},
63-
};
63+
} as JSONLog;
6464
const log2String = getJSONString(log2);
6565
const log3 = {
6666
[LogData.logKeys.level]: "error",
6767
[LogData.logKeys.msg]: "abc ".repeat(cutOffLen) + "group 1",
6868
parentKey1: "k1",
69-
};
69+
} as JSONLog;
7070
const log3String = getJSONString(log3);
7171
const log4 = {
7272
[LogData.logKeys.level]: "info",
7373
[LogData.logKeys.msg]: "qwe ".repeat(cutOffLen) + "group 2",
74-
};
74+
} as JSONLog;
7575
const log4String = getJSONString(log4);
7676
const log5 = {
7777
[LogData.logKeys.level]: "info",
7878
[LogData.logKeys.msg]: "qwe ".repeat(cutOffLen) + "group 2",
79-
};
79+
} as JSONLog;
8080
const log5String = getJSONString(log5);
8181

8282
function getJSONString(obj: any) {
@@ -86,24 +86,21 @@ describe("init", () => {
8686
const file = {
8787
name: "my-file.txt",
8888
size: "1024",
89-
text: () =>
90-
Promise.resolve(
91-
`
92-
${log0String}
93-
${log1String}
94-
"non-json log"
95-
${log2String}
96-
97-
${log3String}
98-
99-
${log4String}
100-
${log5String}
101-
`
102-
),
10389
};
10490

91+
function* logsIterator(): LogsGenerator {
92+
yield log0;
93+
yield log1;
94+
yield null;
95+
yield log2;
96+
yield null;
97+
yield log3;
98+
yield log4;
99+
yield log5;
100+
}
101+
105102
const logData = new LogData();
106-
await logData.init(file as any);
103+
logData.init(file as any, logsIterator);
107104

108105
expect(logData.fileInfo.name, "file name").toEqual(file.name);
109106
expect(logData.fileInfo.size, "file size").toEqual(file.size);

0 commit comments

Comments
 (0)