High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
fix: the bridge ignores server.logLevel, so a configured level dies where faults are diagnosed (PIN-092)
Luigi Agosti7305fc53cfe0
diff --git a/cmd/pinchtab/cmd_bridge.go b/cmd/pinchtab/cmd_bridge.goindex db7072e2..c574c74f 100644--- a/cmd/pinchtab/cmd_bridge.go+++ b/cmd/pinchtab/cmd_bridge.go@@ -14,6 +14,7 @@ var (bridgeCDPAttach stringbridgeBrowser stringbridgeRemoteBrowserName string+ bridgeLogLevel stringbridgeBind stringbridgePort string)@@ -58,6 +59,7 @@ Examples:if v := strings.TrimSpace(bridgeRemoteBrowserName); v != "" {cfg.RemoteBrowserName = v}+ resolveLogLevel(cfg, bridgeLogLevel, false)server.RunBridgeServer(cfg, version)return nil@@ -118,6 +120,7 @@ func init() {bridgeCmd.Flags().StringVar(&bridgeBind, "bind", "", "Bind address for the bridge HTTP server (overrides config server.bind)")bridgeCmd.Flags().StringVar(&bridgePort, "port", "", "Port for the bridge HTTP server (overrides config server.port)")bridgeCmd.Flags().StringVar(&bridgeBrowser, "browser", "", "Browser to use: chrome, cloak, or ghost-chrome (overrides config)")+ bridgeCmd.Flags().StringVar(&bridgeLogLevel, "log-level", "", "Minimum log level: debug, info (default), warn or error (overrides config server.logLevel)")bridgeCmd.Flags().StringVar(&bridgeRemoteBrowserName, "remote-browser-name", "", "Opaque label for the externally-managed browser; surfaces in /stealth/status")rootCmd.AddCommand(bridgeCmd)}diff --git a/cmd/pinchtab/cmd_server.go b/cmd/pinchtab/cmd_server.goindex fd38a8d0..eefb1c9f 100644--- a/cmd/pinchtab/cmd_server.go+++ b/cmd/pinchtab/cmd_server.go@@ -99,12 +99,11 @@ func applyServerAddressFlags(cfg *config.RuntimeConfig, bind, port string) {}}-// resolveLogLevel settles the run's threshold from the only three inputs that-// carry it, in precedence order: --log-level, then server.logLevel from the config-// file, then -v, then the default. It is one function because the command must not-// be able to apply them in a different order — assigning the flag unconditionally-// erased server.logLevel on every flagless run, which is every daemon-installed-// and auto-started server.+// resolveLogLevel settles a run's threshold from the only inputs that carry it, in+// precedence order: --log-level, then server.logLevel from the config file, then+// -v, then the default. Every command that logs calls this rather than assigning+// cfg.LogLevel itself — an unconditional assignment erased server.logLevel on+// every flagless run, which is every daemon-installed and auto-started server.func resolveLogLevel(cfg *config.RuntimeConfig, logLevel string, verbose bool) {if v := strings.TrimSpace(logLevel); v != "" {cfg.LogLevel = vdiff --git a/cmd/pinchtab/cmd_server_test.go b/cmd/pinchtab/cmd_server_test.goindex a3a66108..9bfda27e 100644--- a/cmd/pinchtab/cmd_server_test.go+++ b/cmd/pinchtab/cmd_server_test.go@@ -217,3 +217,41 @@ func TestServerCommandAssignsTheLogLevelOnlyInsideResolveLogLevel(t *testing.T)t.Error("the server command no longer calls resolveLogLevel with the flag and the verbose flag")}}++// The bridge is where a browser-level fault is diagnosed, and server.logLevel now+// travels into every child bridge config, so a bridge that ignored the key would+// drop the operator's debug request exactly where they asked for it.+func TestBridgeResolvesTheConfiguredLogLevel(t *testing.T) {+ t.Cleanup(func() { safelog.SetLevel(safelog.DefaultLevel) })++ for _, tc := range []struct {+ name string+ configLevel string+ flag string+ want slog.Level+ }{+ {name: "config alone is honoured", configLevel: "warn", want: slog.LevelWarn},+ {name: "flag beats config", configLevel: "warn", flag: "debug", want: slog.LevelDebug},+ {name: "neither is the default", want: safelog.DefaultLevel},+ } {+ t.Run(tc.name, func(t *testing.T) {+ safelog.SetLevel(slog.LevelInfo)+ cfg := &config.RuntimeConfig{LogLevel: tc.configLevel}+ resolveLogLevel(cfg, tc.flag, false)+ if got := safelog.CurrentLevel(); got != tc.want {+ t.Errorf("level = %v, want %v", got, tc.want)+ }+ })+ }++ if bridgeCmd.Flags().Lookup("log-level") == nil {+ t.Error("bridge has no --log-level flag, so it cannot override the configured level the way --bind and --port do")+ }+ raw, err := os.ReadFile("cmd_bridge.go")+ if err != nil {+ t.Fatal(err)+ }+ if !strings.Contains(string(raw), "resolveLogLevel(cfg, bridgeLogLevel, false)") {+ t.Error("cmd_bridge.go no longer resolves the log level, so server.logLevel is silently ignored in the bridge")+ }+}diff --git a/docs/commands.md b/docs/commands.mdindex f65dd7fd..6c437c92 100644--- a/docs/commands.md+++ b/docs/commands.md@@ -22,14 +22,15 @@ pinchtab completion <shell> # Generate shell completionsLogging is a level, not an on/off switch. Every run — foreground or `--background`— records the per-request access log (with its `requestId`), instance lifecycle-transitions, warnings and errors. `-v` adds debug detail and the full startup-banner; `--log-level debug|info|warn|error` sets the threshold explicitly and is-the only thing that can drop request lines or warnings.--A daemon-installed server and the server a bare `pinchtab nav` auto-starts both-run `pinchtab server` with no flags, so they take their threshold from-`server.logLevel` in the config file (`pinchtab config set server.logLevel warn`).-`--log-level` overrides it for a hand-started run; `-v` does not.+transitions, warnings and errors. The threshold comes from the first of these that+is set: `--log-level debug|info|warn|error`, then `server.logLevel` in the config+file, then `-v`, then the default `info`. `-v` always adds the full startup banner,+and it raises the level to debug only when neither of the other two is set.++A daemon-installed server and the server a bare `pinchtab nav` auto-starts both run+`pinchtab server` with no flags, so `server.logLevel` is the only way to set their+threshold (`pinchtab config set server.logLevel warn`). `pinchtab bridge` takes the+same key and the same `--log-level` flag.## Navigationdiff --git a/docs/reference/config.md b/docs/reference/config.mdindex a1cd7734..e7fc7241 100644--- a/docs/reference/config.md+++ b/docs/reference/config.md@@ -567,7 +567,11 @@ pinchtab config get server.logLevelAccepted values are `debug`, `info` (the default), `warn` and `error`; anunparseable value fails when the config loads, naming the accepted values.-`--log-level` still wins over the configured value, and `-v` wins over neither.+`--log-level` still wins over the configured value. `-v` keeps its startup banner+either way, but it only raises the level when neither `--log-level` nor+`server.logLevel` is set — so a persisted `warn` survives `pinchtab server -v`, and+`--log-level debug` is how you override it for one run. `pinchtab bridge` reads the+same key and accepts the same flag.### Network Bind With Token