Skip to content

Commit 80df329

Browse files
committed
feat: improve logging entry resolving
1 parent cfc88bc commit 80df329

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

src/lib/logging/scopes/get-log-entry-information.ts

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,39 +16,41 @@ export function getLogEntryInformation(line: string | [number, string]): LogEntr
1616
};
1717
const actualLine = typeof line === "string" ? line : line[1];
1818

19+
switch (actualLine) {
20+
case "__kaede-trigger-initial": {
21+
current.target = "All logs will be displayed here ᓀ‸ᓂ";
22+
23+
return current;
24+
}
25+
case "__kaede-trigger-virtualized": {
26+
current.target = "Virtualized mode. All logs will be displayed here ᓀ‸ᓂ";
27+
28+
return current;
29+
}
30+
case "__kaede-trigger-loading": {
31+
current.target = "Loading your logs...";
32+
33+
return current;
34+
}
35+
}
36+
1937
/*
2038
* Log entries start with the square bracket symbol and the date.
2139
* If the character after the '[' symbol is not a number,
2240
* then the provided line is not a log entry
2341
*/
24-
if (actualLine?.[0] !== "[" || Number.isNaN(
25-
Number(actualLine?.[1]),
26-
)) {
42+
const isLogEntry =
43+
actualLine?.[0] === "[" &&
44+
!Number.isNaN(Number(actualLine?.[1]));
45+
46+
if (!isLogEntry) {
2747
current.time = actualLine;
2848

2949
return current;
3050
}
3151

3252
const parts = actualLine.split("]");
3353

34-
if (actualLine.startsWith("__kaede-trigger-initial")) {
35-
current.target = "All logs will be displayed here ᓀ‸ᓂ";
36-
37-
return current;
38-
}
39-
40-
if (actualLine.startsWith("__kaede-trigger-virtualized")) {
41-
current.target = "Virtualized mode. All logs will be displayed here ᓀ‸ᓂ";
42-
43-
return current;
44-
}
45-
46-
if (actualLine.startsWith("__kaede-trigger-loading")) {
47-
current.target = "Loading your logs...";
48-
49-
return current;
50-
}
51-
5254
for (const [partIndex, part] of parts.entries()) {
5355
switch (partIndex) {
5456
case 0: {

0 commit comments

Comments
 (0)