Documentation
¶
Overview ¶
Package slog provides a logger that writes to a go.uber.org/slog.Logger.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func NewLogger ¶
Example ¶
package main import ( "context" "io" "log/slog" "github.com/jackc/pgx/v5/pgxpool" "github.com/jackc/pgx/v5/tracelog" slogadapter "github.com/induzo/gocom/database/pgx-slog" ) func main() { textAdapter := slog.NewTextHandler(io.Discard, nil) logger := slog.New(textAdapter) pgxPool, _ := pgxpool.New(context.Background(), "postgres://postgres:postgres@localhost:5432/datawarehouse") pgxPool.Config().ConnConfig.Tracer = &tracelog.TraceLog{ Logger: slogadapter.NewLogger(logger), LogLevel: tracelog.LogLevelTrace, } }
Output:
Click to show internal directories.
Click to hide internal directories.