Add a *log.Logger argument to physical.Factory

Logging in the backend is a good thing.  This is a noisy interface change but should be a functional noop.
This commit is contained in:
Sean Chittenden
2016-04-25 20:10:32 -07:00
parent 27f5b96411
commit 455b76828f
33 changed files with 194 additions and 82 deletions

View File

@@ -3,6 +3,7 @@ package physical
import (
"database/sql"
"fmt"
"log"
"strings"
"time"
@@ -16,11 +17,12 @@ type PostgreSQLBackend struct {
table string
client *sql.DB
statements map[string]*sql.Stmt
logger *log.Logger
}
// newPostgreSQLBackend constructs a PostgreSQL backend using the given
// API client, server address, credentials, and database.
func newPostgreSQLBackend(conf map[string]string) (Backend, error) {
func newPostgreSQLBackend(conf map[string]string, logger *log.Logger) (Backend, error) {
// Get the PostgreSQL credentials to perform read/write operations.
connURL, ok := conf["connection_url"]
if !ok || connURL == "" {
@@ -62,6 +64,7 @@ func newPostgreSQLBackend(conf map[string]string) (Backend, error) {
table: quoted_table,
client: db,
statements: make(map[string]*sql.Stmt),
logger: logger,
}
// Prepare all the statements required