hedhyw / json-log-viewer

Interactive viewer for JSON logs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

feat: support human-readable timestamps

hedhyw opened this issue · comments

Add new kinds:

  • FieldKind=numerictime, timestamp with auto-determination of type (seconds, milli, micro, etc., by the number of digits), use it by default.
  • FieldKind=millitime - timestamp in Unix milliseconds.
  • FieldKind=sectime - timestamp in Unix seconds.
  • FieldKind=microtime - timestamp in Unix microseconds.

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

Resolving this would also resolve #7 correct?

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
}]

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:

case config.FieldKindTime:

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

case config.FieldKindTime:

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