Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion driverbase/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func NewDatabaseImplBase(ctx context.Context, driver *DriverImplBase) (DatabaseI
Alloc: driver.Alloc,
ErrorHelper: driver.ErrorHelper,
DriverInfo: driver.DriverInfo,
Logger: nilLogger(),
Logger: driver.Logger,
Tracer: nilTracer(),
}
err := database.InitTracing(ctx, driver.DriverInfo.GetName(), getDriverVersion(driver.DriverInfo))
Expand Down
11 changes: 11 additions & 0 deletions driverbase/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ package driverbase

import (
"context"
"log/slog"
"runtime/debug"
"strings"

Expand Down Expand Up @@ -74,6 +75,7 @@ type DriverImplBase struct {
Alloc memory.Allocator
ErrorHelper ErrorHelper
DriverInfo *DriverInfo
Logger *slog.Logger
}

func (base *DriverImplBase) NewDatabase(opts map[string]string) (adbc.Database, error) {
Expand Down Expand Up @@ -109,13 +111,22 @@ func NewDriverImplBase(info *DriverInfo, alloc memory.Allocator) DriverImplBase
Alloc: alloc,
ErrorHelper: ErrorHelper{DriverName: info.GetName()},
DriverInfo: info,
Logger: nilLogger(),
}
}

func (base *DriverImplBase) Base() *DriverImplBase {
return base
}

func (base *DriverImplBase) SetLogger(logger *slog.Logger) {
if logger != nil {
base.Logger = logger
} else {
base.Logger = nilLogger()
}
}

type driver struct {
DriverImpl
}
Expand Down
5 changes: 3 additions & 2 deletions sqlwrapper/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"
"database/sql"
"errors"
"log/slog"

"github.com/adbc-drivers/driverbase-go/driverbase"
"github.com/apache/arrow-adbc/go/adbc"
Expand All @@ -40,7 +41,7 @@ type ConnectionFactory interface {
// Each driver is expected to implement this interface to provide database-specific
// DSN construction and connection logic for their particular database format.
type DBFactory interface {
CreateDB(ctx context.Context, driverName string, opts map[string]string) (*sql.DB, error)
CreateDB(ctx context.Context, driverName string, opts map[string]string, logger *slog.Logger) (*sql.DB, error)
}

// Driver provides an ADBC driver implementation that wraps database/sql drivers.
Expand Down Expand Up @@ -120,7 +121,7 @@ func (d *Driver) NewDatabaseWithContext(ctx context.Context, opts map[string]str
}

// Use DB factory to create the *sql.DB from options
sqlDB, err := d.dbFactory.CreateDB(ctx, d.driverName, opts)
sqlDB, err := d.dbFactory.CreateDB(ctx, d.driverName, opts, d.Logger)
if err != nil {
return nil, base.ErrorHelper.WrapInvalidArgument(err, "failed to create database")
}
Expand Down
Loading