338: fix: move highlighting after formatting#339
Merged
Conversation
Contributor
Author
|
more details here in original issue: #338 |
Member
|
I will check the PR this weekend. |
Comment on lines
221
to
225
| if withHighlight { | ||
| fmt.Fprint(t.out, t.Options.HighlightMatchedString(buf.String())) | ||
| return | ||
| } | ||
| fmt.Fprint(t.out, buf.String()) |
Member
There was a problem hiding this comment.
Suggested change
| if withHighlight { | |
| fmt.Fprint(t.out, t.Options.HighlightMatchedString(buf.String())) | |
| return | |
| } | |
| fmt.Fprint(t.out, buf.String()) | |
| fmt.Fprint(t.out, t.Options.HighlightMatchedString(buf.String())) |
Some error messages may be highlighted, but I think the above change is fine.
Contributor
Author
There was a problem hiding this comment.
It's rare case, imho, but if it required, I can add feature to exclude highlight from errors
superbrothers
left a comment
Member
There was a problem hiding this comment.
If possible, I would like you to add tests.
Contributor
Author
Sorry for late update, had no time:( I've added tests! |
|
|
||
| // Print prints a color coded log message | ||
| func (t *FileTail) Print(msg string) { | ||
| func (t *FileTail) Print(msg string, withHighlight bool) { |
Member
There was a problem hiding this comment.
Sorry for the late review.
Instead of adding the withHighlight argument, I would like to add a new PrintWithoutHighlight function that print message without highlight.
func (t *Tail) sprint(msg string) string {
...
}
// Print prints a color coded log message with the pod and container names
func (t *Tail) Print(msg string) {
fmt.Fprint(t.out, t.Options.HighlightMatchedString(t.sprint(msg)))
}
// PrintWithoutHighlight prints a log message without applying any highlight.
func (t *Tail) PrintWithoutHighlight(msg string) {
fmt.Fprint(t.out, t.sprint(msg))
}
superbrothers
approved these changes
May 27, 2025
tmeijn
pushed a commit
to tmeijn/dotfiles
that referenced
this pull request
Sep 9, 2025
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [stern/stern](https://github.com/stern/stern) | minor | `v1.32.0` -> `v1.33.0` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>stern/stern (stern/stern)</summary> ### [`v1.33.0`](https://github.com/stern/stern/blob/HEAD/CHANGELOG.md#v1330) [Compare Source](stern/stern@v1.32.0...v1.33.0) #### ⚡ Notable Changes ##### New template variables `Labels` and `Annotations` You can now use `Labels` and `Annotations` in your templates. ``` stern -n kube-system -l component --template '{{printf "%-25s %s" .Labels.component .Message}}{{"\n"}}' ``` #### Changes - Update dependencies for Kubernetes 1.34 ([#​349](stern/stern#349)) [`d6a0679`](stern/stern@d6a0679) (Takashi Kusumi) - Fix asdf installation typo ([#​348](stern/stern#348)) [`5946e7f`](stern/stern@5946e7f) (Guruprasad Bhat) - 338: fix: move highlighting after formatting ([#​339](stern/stern#339)) [`6d915a8`](stern/stern@6d915a8) (Peter) - Add support for labels & annotations in templates ([#​344](stern/stern#344)) [`3cd85b4`](stern/stern@3cd85b4) (Nicholas Hurden) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS45Ny45IiwidXBkYXRlZEluVmVyIjoiNDEuOTcuOSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes issue: 338
Highlighting was moved after templating