improve debug feature for gdb; add skip support for file line print for glog

This commit is contained in:
John
2019-07-15 19:54:13 +08:00
parent 9c857705ff
commit e484685282
5 changed files with 9 additions and 13 deletions

View File

@ -340,11 +340,8 @@ func (bs *dbBase) getSqlDb(master bool) (sqlDb *sql.DB, err error) {
sqlDb = v.(*sql.DB)
}
// 是否开启调试模式
switch node.Debug {
case 1:
bs.db.SetDebug(false)
case 2:
bs.db.SetDebug(true)
if node.Debug {
bs.db.SetDebug(node.Debug)
}
// 是否手动选择数据库
if v := bs.schema.Val(); v != "" {

View File

@ -32,7 +32,7 @@ type ConfigNode struct {
Name string // 数据库名称
Type string // 数据库类型mysql, sqlite, mssql, pgsql, oracle
Role string // (可选默认为master)数据库的角色用于主从操作分离至少需要有一个master参数值master, slave
Debug int // (可选)开启调试模式(0:未设置1:关闭2:开启)
Debug bool // (可选)开启调试模式
Weight int // (可选)用于负载均衡的权重计算,当集群中只有一个节点时,权重没有任何意义
Charset string // (可选,默认为 utf8)编码,默认为 utf8
LinkInfo string // (可选)自定义链接信息,当该字段被设置值时,以上链接字段(Host,Port,User,Pass,Name)将失效(该字段是一个扩展功能)

View File

@ -63,6 +63,9 @@ func (tx *TX) Table(tables string) *Model {
tx: tx,
tablesInit: tables,
tables: tables,
fields: "*",
start: -1,
offset: -1,
safe: false,
}
}

View File

@ -161,11 +161,7 @@ func parseDBConfigNode(value interface{}) *gdb.ConfigNode {
node.Role = gconv.String(value)
}
if value, ok := nodeMap["debug"]; ok {
if gconv.Bool(value) {
node.Debug = 2
} else {
node.Debug = 1
}
node.Debug = gconv.Bool(value)
}
if value, ok := nodeMap["charset"]; ok {
node.Charset = gconv.String(value)

View File

@ -244,10 +244,10 @@ func (l *Logger) print(std io.Writer, lead string, value ...interface{}) {
// Caller path.
callerPath := ""
if l.flags&F_FILE_LONG > 0 {
callerPath = debug.CallerWithFilter(gPATH_FILTER_KEY) + ": "
callerPath = debug.CallerWithFilter(gPATH_FILTER_KEY, l.stSkip) + ": "
}
if l.flags&F_FILE_SHORT > 0 {
callerPath = gfile.Basename(debug.CallerWithFilter(gPATH_FILTER_KEY)) + ": "
callerPath = gfile.Basename(debug.CallerWithFilter(gPATH_FILTER_KEY, l.stSkip)) + ": "
}
if len(callerPath) > 0 {
buffer.WriteString(callerPath)