Skip to content

feat: adds option to tail logs #278

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

Merged
merged 10 commits into from
May 6, 2025
Merged

feat: adds option to tail logs #278

merged 10 commits into from
May 6, 2025

Conversation

ChrisJBurns
Copy link
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 <[email protected]>
@ChrisJBurns ChrisJBurns requested a review from JAORMX April 25, 2025 19:18
},
}

logsCommand.Flags().BoolVarP(&tailFlag, "tail", "t", false, "Tail the logs")
Copy link
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
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