add internal logging for package gdb/gredis

This commit is contained in:
John Guo 2021-03-11 11:39:49 +08:00
parent 20f2a6c003
commit 7702c5bfde
2 changed files with 7 additions and 1 deletions

View File

@ -473,9 +473,13 @@ func (c *Core) getSqlDb(master bool, schema ...string) (sqlDb *sql.DB, err error
v, _ := internalCache.GetOrSetFuncLock(node.String(), func() (interface{}, error) {
sqlDb, err = c.db.Open(node)
if err != nil {
intlog.Printf("DB open failed: %v, %+v", err, node)
intlog.Printf(`db open failed: %v, %+v`, err, node)
return nil, err
}
intlog.Printf(
`open new connection, master:%v, config:%+v, node:%+v`,
master, c.config, node,
)
if c.config.MaxIdleConnCount > 0 {
sqlDb.SetMaxIdleConns(c.config.MaxIdleConnCount)
} else {

View File

@ -16,6 +16,7 @@ package gredis
import (
"context"
"fmt"
"github.com/gogf/gf/internal/intlog"
"time"
"github.com/gogf/gf/container/gmap"
@ -113,6 +114,7 @@ func New(config *Config) *Redis {
if err != nil {
return nil, err
}
intlog.Printf(`open new connection, config:%+v`, config)
// AUTH
if len(config.Pass) > 0 {
if _, err := c.Do("AUTH", config.Pass); err != nil {