Add bns logs command for streaming container logs#72
Merged
alexo-bunnyshell merged 4 commits intomasterfrom Jan 19, 2026
Merged
Add bns logs command for streaming container logs#72alexo-bunnyshell merged 4 commits intomasterfrom
alexo-bunnyshell merged 4 commits intomasterfrom
Conversation
Implement a new top-level 'bns logs' command that streams container application logs (stdout/stderr) from Kubernetes pods with support for multi-component streaming and multiple output formats. Features: - Stream logs from single or multiple components - Environment-wide log streaming (--environment flag) - Component filtering by ID or name (--name flag) - Context fallback support - kubectl-compatible flags (--follow, --tail, --since, --timestamps, etc.) - Thread-safe merged output from multiple sources - Color-coded prefixes for easy identification [component/pod/container] - Multiple output formats: stylish (default), JSON, YAML - Graceful error handling and signal interruption (Ctrl+C) New files: - cmd/logs/root.go - Main command implementation with component resolution - pkg/k8s/kubectl/logs/logs.go - K8s log streaming wrapper - pkg/k8s/kubectl/logs/multiplexer.go - Concurrent streaming coordinator Modified files: - cmd/utils/root.go - Register logs command Usage examples: bns logs --environment env-123 --follow --tail 100 bns logs --component comp-1,comp-2 --follow bns logs --environment env-123 --name api --name worker -o json bns logs --component comp-123 --since 5m --timestamps Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Move examples from Long to Example field for proper Cobra formatting - Remove manual Flags documentation from Long field - Let Cobra automatically generate the Flags section - Improves help readability by eliminating duplication
Resolve conflict in cmd/utils/root.go by including both exec and logs commands
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.
Summary
This PR adds a new top-level
bns logscommand that streams container application logs (stdout/stderr) from Kubernetes pods with support for multi-component streaming and multiple output formats.Key Features:
--environmentflag streams all components)--nameflag, repeatable)--follow,--tail,--since,--since-time,--timestamps,--previous[component/pod/container]Architecture:
bns execcommand (top-level utility command)Pods().GetLogs()APINew Files:
cmd/logs/root.go(524 lines) - Main command with component resolution and orchestrationpkg/k8s/kubectl/logs/logs.go(142 lines) - K8s log streaming wrapperpkg/k8s/kubectl/logs/multiplexer.go(377 lines) - Concurrent streaming coordinator with JSON/YAML writersModified Files:
cmd/utils/root.go- Register logs command alongside exec, git, etc.Usage Examples
Output Formats
Stylish (default):
JSON:
{"timestamp":"2026-01-17T23:54:32Z","component":"vote","componentId":"5qzDbeXOmg","pod":"vote-7c6d4d6b8-85k5h","container":"vote","namespace":"env-homi2s","message":"127.0.0.1 - - [17/Jan/2026 23:54:08] \"GET / HTTP/1.1\" 200 -"}YAML:
Test Plan
--component)--environment)--name, multiple names)--follow)--tail)--since)--timestamps)-o json)-o yaml)Tested with:
jqfor filteringNotes
🤖 Generated with Claude Code