Skip to content

281: Support toTimestamp template function#282

Merged
tksm merged 1 commit intostern:masterfrom
WillAnd31:281-to-timestamp
Oct 22, 2023
Merged

281: Support toTimestamp template function#282
tksm merged 1 commit intostern:masterfrom
WillAnd31:281-to-timestamp

Conversation

@WillAnd31
Copy link
Contributor

This PR adds support for a new template function toTimestamp, mentioned in #281. The toTimestamp function takes in an object, a layout, and optionally a timezone. This allows for more custom time parsing, for instance, if a user doesn't care about seeing the date of the log and only the time (in their own timezone) they can use a template such as:

--template '{{ with $msg := .Message | tryParseJSON }}[{{ toTimestamp $msg.time "15:04:05" "Local" }}] {{ $msg.msg }}{{ end }}{{ "\n" }}'

Copy link
Contributor

@tksm tksm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@tksm tksm merged commit 5445cd5 into stern:master Oct 22, 2023
@WillAnd31
Copy link
Contributor Author

Thank you @tksm!

@WillAnd31 WillAnd31 deleted the 281-to-timestamp branch October 22, 2023 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants