Skip to content
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

[Question] Timestamp format on json template #18

Closed
josemnbcamacho opened this issue Dec 15, 2020 · 1 comment · Fixed by #20 or VelvetToroyashi/Silk#200
Closed

[Question] Timestamp format on json template #18

josemnbcamacho opened this issue Dec 15, 2020 · 1 comment · Fixed by #20 or VelvetToroyashi/Silk#200

Comments

@josemnbcamacho
Copy link

josemnbcamacho commented Dec 15, 2020

Hi,

I'm trying to use a timestamp formatter in a json template like

"{ {timestamp: @t:o, level: @l, sourceContext: SourceContext, message: @m} }\n"

Can't manage to get the formatted timestamp, it seems that the parser is not expecting the ":" after "@t".

Is this something supported?

Regards,
José

@nblumhardt
Copy link
Member

Hi Jose - unfortunately, this syntax isn't supported; o should be the default format for datetimes, IIRC, so you may not need it at all (?), but otherwise, plugging in a ToString() user-defined function would be the only way to work around this right now:

"{ {timestamp: ToString(@t, 'o'), level: @l, sourceContext: SourceContext, message: @m} }\n"

We might add a ToString(x, format) built-in function to handle these kinds of cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants