{"modulePath":"github.com/databricks/databricks-sql-go/v2","version":"v2.0.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package debuglog\n\nPackage debuglog is the step-level debug tracer for the databricks-sql-go SEA/kernel integration.\n\nThe SEA-via-kernel path crosses a Go-GC \\\u003c-\u003e Rust-ownership FFI boundary where failures are silent and non-local (thread migration, use-after-free, thread blowup, cross-region latency that looks like \"the protocol is slow\"). A Go stack trace stops at the cgo edge, so the way to see which step failed or slowed down is an explicit, ordered, timed, per-function log at each step — in particular an \"enter\" line emitted \\*before\\* a step runs, so a step that hangs at the FFI edge (and never returns) is still visible.\n\nThis is a thin helper over the driver's single logger (logger.Logger): every event is an ordinary debug-level line on the same sink, in the same format (JSON in production, pretty in a terminal) as the rest of the driver's logs. There is no second logger and no separate output knob — turn it on the way you turn on any driver logging, with logger.SetLogLevel(\"debug\") or DATABRICKS\\_LOG\\_LEVEL=debug. That keeps these lines readable next to the existing driver logs and lets kernel-side logs (written to the same stderr) interleave into one stream in execution order.\n\nEach event carries the function the step is in, the phase (\"enter\"/\"done\", omitted for a point log), the elapsed time (on \"done\"), and the conn/correlation/query ids from the context. The shared logger supplies the timestamp and level fields, so the format matches every other driver line.\n\n## Functions\n\n```go\nfunc Enabled() bool\n```\nEnabled reports whether debug-level logging is currently on, i.e. whether events would be emitted. Cheap enough to call at every step; callers use it to skip building expensive log arguments. It simply reflects the driver's log level, so debug tracing follows SetLogLevel like every other driver log.\n\n```go\nfunc Logf(ctx context.Context, fn string, format string, args ...any)\n```\nLogf emits a single function-tagged step event at debug level. fn is the function the step is in (e.g. \"thrift.Backend.Execute\"); the format/args describe the step. No-op when debug logging is off (the underlying event is nil and discards cheaply) — guard the call with Enabled() if the args are expensive to build.\n\n```go\nfunc Track(ctx context.Context, fn string, format string, args ...any) func()\n```\nTrack marks the start of a step and returns a function that logs the step's elapsed time. Intended for \\`defer\\`:\n\n\tdefer debuglog.Track(ctx, \"thrift.Backend.Execute\", \"sql.len=%d\", len(query))()\n\nThe enter event is emitted immediately (so a step that never returns is still visible); the returned closure emits a matching done event carrying the elapsed duration. Both are no-ops when debug logging is off, and the returned closure is always safe to call.\n\n","path":"github.com/databricks/databricks-sql-go/v2/internal/debuglog","name":"debuglog","synopsis":"Package debuglog is the step-level debug tracer for the databricks-sql-go SEA/kernel integration.","isRedistributable":true}
