hedhyw / json-log-viewer

Interactive viewer for JSON logs.
MIT License
77 stars 7 forks source link

feat: support human-readable timestamps #36

Closed hedhyw closed 9 months ago

hedhyw commented 9 months ago

Add new kinds:

If the value is a number then convert it to a string (RFC3339), otherwise show it as is. Support float.

cosmastech commented 9 months ago

Resolving this would also resolve https://github.com/hedhyw/json-log-viewer/issues/7 correct?

cosmastech commented 9 months ago

Is it expected that the time column is always encoded as a string, or is possible that the raw JSON might be like:

[{
    "time": 1234.2
}]
hedhyw commented 9 months ago

Is it expected that the time column is always encoded as a string, or is possible that the raw JSON might be like:

It can be:

[{
    "time": 1234.2
}, {
    "time": 1234
}, {
    "time": "1234"
}]

but actually, it is not a big problem since we have a string as an input: https://github.com/hedhyw/json-log-viewer/blob/c8ce24a6c88470870215aca60808c76124cc57ea/internal/pkg/source/entry.go#L103

cosmastech commented 9 months ago

but actually, it is not a big problem since we have a string as an input:

https://github.com/hedhyw/json-log-viewer/blob/c8ce24a6c88470870215aca60808c76124cc57ea/internal/pkg/source/entry.go#L103

Thanks for the feedback.

There actually looks to be an issue calling strconv.Unquote() if the value is a non-string. My proposal for how to work around this is included in the PR I'm working on. https://github.com/hedhyw/json-log-viewer/pull/38/files#diff-fe24c90fd92a660740201af245c3d85f0751d5b998634662896e0a2762eb7848R84-R88