-
Notifications
You must be signed in to change notification settings - Fork 10
feat: Colorize json if detected #485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
e64f8c0 to
fe5667c
Compare
Signed-off-by: Hettinger, David <DHETTINGER@quad.com>
Signed-off-by: Hettinger, David <DHETTINGER@quad.com>
Signed-off-by: Hettinger, David <DHETTINGER@quad.com>
fe5667c to
92a2f4c
Compare
Signed-off-by: Adameska <hettinger14@outlook.com>
gastoner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| expect(result2).toContain('\u001b[36m'); | ||
| }); | ||
|
|
||
| test('should handle abbreviated log levels', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please use test.each? Here is an example https://github.com/podman-desktop/podman-desktop/blob/main/extensions/podman/packages/extension/src/extension.spec.ts#L399
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes i can update that.
| }); | ||
|
|
||
| test('should handle full word log levels', () => { | ||
| const testCases = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
| * @param lines - Array of log lines to analyze | ||
| * @returns true if logs should be treated as JSON format | ||
| */ | ||
| export function detectJsonLogs(lines: string[]): boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be possible to do this for every line of logs? WDYT @feloy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logs may have thousands of lines. And generally, all lines are in Json format, or none of them are, so this test seems legit to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer this route, the less i have to know/do the better... and colorizing lots of lines of json was plenty fast for me on my machine but the concern is valid. We could also add a menu option here if/when this PR gets completed to drive this behavior too... #417

Signed-off-by: Adameska <hettinger14@outlook.com>

Logs before:

Logs after:
