Skip to content

Commit a022cc1

Browse files
Add --verbose flag to bypass log filtering (#140)
1 parent 20b1038 commit a022cc1

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Running `lstk` will automatically handle configuration setup and start LocalStac
4848
- **Start / stop / status** — manage LocalStack emulators with a single command
4949
- **Interactive TUI** — a Bubble Tea-powered terminal UI when run in an interactive shell
5050
- **Plain output** for CI/CD and scripting (auto-detected in non-interactive environments or forced with `--non-interactive`)
51-
- **Log streaming** — tail emulator logs in real-time with `--follow`
51+
- **Log streaming** — tail emulator logs in real-time with `--follow`; use `--verbose` to show all logs without filtering
5252
- **Browser-based login** — authenticate via browser and store credentials securely in the system keyring
5353
- **AWS CLI profile** — optionally configure a `localstack` profile in `~/.aws/` after start
5454
- **Self-update** — check for and install the latest `lstk` release with `lstk update`
@@ -161,6 +161,9 @@ lstk status
161161
# Stream emulator logs
162162
lstk logs --follow
163163

164+
# Stream all emulator logs without filtering
165+
lstk logs --follow --verbose
166+
164167
# Log in (opens browser for authentication)
165168
lstk login
166169

cmd/logs.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99
"github.com/localstack/lstk/internal/env"
1010
"github.com/localstack/lstk/internal/output"
1111
"github.com/localstack/lstk/internal/runtime"
12-
"github.com/localstack/lstk/internal/ui"
1312
"github.com/localstack/lstk/internal/telemetry"
13+
"github.com/localstack/lstk/internal/ui"
1414
"github.com/spf13/cobra"
1515
)
1616

@@ -25,6 +25,10 @@ func newLogsCmd(cfg *env.Env, tel *telemetry.Client) *cobra.Command {
2525
if err != nil {
2626
return err
2727
}
28+
verbose, err := cmd.Flags().GetBool("verbose")
29+
if err != nil {
30+
return err
31+
}
2832
rt, err := runtime.NewDockerRuntime(cfg.DockerHost)
2933
if err != nil {
3034
return err
@@ -34,11 +38,12 @@ func newLogsCmd(cfg *env.Env, tel *telemetry.Client) *cobra.Command {
3438
return fmt.Errorf("failed to get config: %w", err)
3539
}
3640
if isInteractiveMode(cfg) {
37-
return ui.RunLogs(cmd.Context(), rt, appConfig.Containers, follow)
41+
return ui.RunLogs(cmd.Context(), rt, appConfig.Containers, follow, verbose)
3842
}
39-
return container.Logs(cmd.Context(), rt, output.NewPlainSink(os.Stdout), appConfig.Containers, follow)
43+
return container.Logs(cmd.Context(), rt, output.NewPlainSink(os.Stdout), appConfig.Containers, follow, verbose)
4044
}),
4145
}
4246
cmd.Flags().BoolP("follow", "f", false, "Follow log output")
47+
cmd.Flags().BoolP("verbose", "v", false, "Show all log output without filtering")
4348
return cmd
4449
}

internal/container/logs.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/localstack/lstk/internal/runtime"
1212
)
1313

14-
func Logs(ctx context.Context, rt runtime.Runtime, sink output.Sink, containers []config.ContainerConfig, follow bool) error {
14+
func Logs(ctx context.Context, rt runtime.Runtime, sink output.Sink, containers []config.ContainerConfig, follow bool, verbose bool) error {
1515
if len(containers) == 0 {
1616
return fmt.Errorf("no containers configured")
1717
}
@@ -30,7 +30,7 @@ func Logs(ctx context.Context, rt runtime.Runtime, sink output.Sink, containers
3030
scanner := bufio.NewScanner(pr)
3131
for scanner.Scan() {
3232
line := scanner.Text()
33-
if shouldFilter(line) {
33+
if !verbose && shouldFilter(line) {
3434
continue
3535
}
3636
level, _ := parseLogLine(line)

internal/ui/run_logs.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"github.com/localstack/lstk/internal/runtime"
1313
)
1414

15-
func RunLogs(parentCtx context.Context, rt runtime.Runtime, containers []config.ContainerConfig, follow bool) error {
15+
func RunLogs(parentCtx context.Context, rt runtime.Runtime, containers []config.ContainerConfig, follow bool, verbose bool) error {
1616
ctx, cancel := context.WithCancel(parentCtx)
1717
defer cancel()
1818

@@ -21,7 +21,7 @@ func RunLogs(parentCtx context.Context, rt runtime.Runtime, containers []config.
2121
runErrCh := make(chan error, 1)
2222

2323
go func() {
24-
err := container.Logs(ctx, rt, output.NewTUISink(programSender{p: p}), containers, follow)
24+
err := container.Logs(ctx, rt, output.NewTUISink(programSender{p: p}), containers, follow, verbose)
2525
runErrCh <- err
2626
if err != nil && !errors.Is(err, context.Canceled) {
2727
p.Send(runErrMsg{err: err})

0 commit comments

Comments
 (0)