From 599772a8fd2a9805b9e0d98879464e96b865fecd Mon Sep 17 00:00:00 2001 From: "Ariel Shaqed (Scolnicov)" Date: Wed, 26 Aug 2020 11:47:48 +0300 Subject: [PATCH] [CR] Take logger *only* from context --- db/database.go | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/db/database.go b/db/database.go index bc758f8e30b..f3cf6f67f44 100644 --- a/db/database.go +++ b/db/database.go @@ -26,7 +26,6 @@ type Database interface { Metadata() (map[string]string, error) Stats() sql.DBStats WithContext(ctx context.Context) Database - WithLogger(logger logging.Logger) Database } type QueryOptions struct { @@ -47,7 +46,7 @@ func (d *SqlxDatabase) getLogger() logging.Logger { if d.queryOptions != nil { return d.queryOptions.logger } - return logging.Default().WithContext(d.getContext()) + return logging.Default() } func (d *SqlxDatabase) getContext() context.Context { @@ -61,22 +60,12 @@ func (d *SqlxDatabase) WithContext(ctx context.Context) Database { return &SqlxDatabase{ db: d.db, queryOptions: &QueryOptions{ - logger: d.getLogger(), + logger: logging.Default().WithContext(ctx), ctx: ctx, }, } } -func (d *SqlxDatabase) WithLogger(logger logging.Logger) Database { - return &SqlxDatabase{ - db: d.db, - queryOptions: &QueryOptions{ - logger: logger, - ctx: d.getContext(), - }, - } -} - func (d *SqlxDatabase) Close() error { return d.db.Close() }