diff --git a/client_internal.go b/client_internal.go index ea50f9cc..fb036d4b 100644 --- a/client_internal.go +++ b/client_internal.go @@ -47,9 +47,11 @@ func (c *Client) loadDatastore(ctx context.Context) (err error) { } // Load client (runs ALL options, IE: auto migrate models) - c.options.dataStore.ClientInterface, err = datastore.NewClient( - ctx, c.options.dataStore.options..., - ) + if c.options.dataStore.ClientInterface == nil { + c.options.dataStore.ClientInterface, err = datastore.NewClient( + ctx, c.options.dataStore.options..., + ) + } return } diff --git a/client_options.go b/client_options.go index 6e2bee69..da73793c 100644 --- a/client_options.go +++ b/client_options.go @@ -202,18 +202,10 @@ func WithDebugging() ClientOps { c.debug = true // Enable debugging on other services - if c.chainstate != nil { - c.chainstate.options = append(c.chainstate.options, chainstate.WithDebugging()) - } - if c.cacheStore != nil { - c.cacheStore.options = append(c.cacheStore.options, cachestore.WithDebugging()) - } - if c.dataStore != nil { - c.dataStore.options = append(c.dataStore.options, datastore.WithDebugging()) - } - if c.taskManager != nil { - c.taskManager.options = append(c.taskManager.options, taskmanager.WithDebugging()) - } + c.cacheStore.options = append(c.cacheStore.options, cachestore.WithDebugging()) + c.chainstate.options = append(c.chainstate.options, chainstate.WithDebugging()) + c.dataStore.options = append(c.dataStore.options, datastore.WithDebugging()) + c.taskManager.options = append(c.taskManager.options, taskmanager.WithDebugging()) } } diff --git a/datastore/client.go b/datastore/client.go index 353bee61..898b48b6 100644 --- a/datastore/client.go +++ b/datastore/client.go @@ -49,6 +49,11 @@ func NewClient(ctx context.Context, opts ...ClientOps) (ClientInterface, error) opt(client.options) } + // Set logger if not set now + if client.options.logger == nil { + client.options.logger = newBasicLogger(client.IsDebug()) + } + // EMPTY! Engine was NOT set and will use the default (file based) if client.Engine().IsEmpty() { @@ -105,11 +110,6 @@ func NewClient(ctx context.Context, opts ...ClientOps) (ClientInterface, error) } } - // Set logger if not set now - if client.options.logger == nil { - client.options.logger = newBasicLogger(client.IsDebug()) - } - // Return the client return client, nil } @@ -159,7 +159,7 @@ func (c *Client) IsNewRelicEnabled() bool { // DebugLog will display verbose logs func (c *Client) DebugLog(text string) { - if c.options.debug && c.options.logger != nil { + if c.IsDebug() && c.options.logger != nil { c.options.logger.Info(context.Background(), text) } }