Skip to content

feat: adds option to tail logs#278

Merged
ChrisJBurns merged 10 commits intomainfrom
container-log-tailing
May 6, 2025
Merged

feat: adds option to tail logs#278
ChrisJBurns merged 10 commits intomainfrom
container-log-tailing

Conversation

@ChrisJBurns
Copy link
Copy Markdown
Collaborator

@ChrisJBurns ChrisJBurns commented Apr 25, 2025

Description

Previous to this PR, there was no way of tailing the logs, you had to continually run thv logs $SERVER_NAME to get the logs. Now, with the addition of the -t flag to thv logs $SERVER_NAME we can tail the last 100 log lines. If we want to make the 100 configurable, we can, thought I'd set a sensible default for now.

Changes

  • adds -t tail flag to the logs subcommand
  • refactored the logs command so that the code itself is in a separate function. none of the code has been removed, just moved into a separate function for readability
  • uses RunE so we can return errors from the subcommands up to the main

Ref: #202

Signed-off-by: ChrisJBurns <29541485+ChrisJBurns@users.noreply.github.com>
Signed-off-by: ChrisJBurns <29541485+ChrisJBurns@users.noreply.github.com>
@ChrisJBurns ChrisJBurns requested a review from JAORMX April 25, 2025 19:18
Signed-off-by: ChrisJBurns <29541485+ChrisJBurns@users.noreply.github.com>
Signed-off-by: ChrisJBurns <29541485+ChrisJBurns@users.noreply.github.com>
Signed-off-by: ChrisJBurns <29541485+ChrisJBurns@users.noreply.github.com>
Signed-off-by: ChrisJBurns <29541485+ChrisJBurns@users.noreply.github.com>
},
}

logsCommand.Flags().BoolVarP(&tailFlag, "tail", "t", false, "Tail the logs")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

should we make this an IntVarP and pass the 100 that's the default?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Not sure if we can make 100 the default here as that would mean it always tails 100 lines. We need a flag that allows users to tail or just output. However, I can add another variable that is an IntVarP that defaults to 100 and instead outputs the last 100 lines OR it will only tail the last 100 lines.

@ChrisJBurns ChrisJBurns merged commit 214c411 into main May 6, 2025
9 of 10 checks passed
@ChrisJBurns ChrisJBurns deleted the container-log-tailing branch May 6, 2025 21:10
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