[MM-19422] Add SQL trace and LDAP trace output to both console and server logs (#13190)
* Add MLOG for sql store * Update printf function * Update store/sqlstore/supplier.go Co-Authored-By: Martin Kraft <martin@upspin.org> * Update go mod * update go mod and tidy it up * update vendor folder
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
a83df931b9
Коммит
de0672937c
@@ -9,7 +9,6 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
sqltrace "log"
|
||||
"os"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
@@ -114,6 +113,16 @@ type SqlSupplier struct {
|
||||
lockedToMaster bool
|
||||
}
|
||||
|
||||
type TraceOnAdapter struct{}
|
||||
|
||||
func (t *TraceOnAdapter) Printf(format string, v ...interface{}) {
|
||||
originalString := fmt.Sprintf(format, v...)
|
||||
newString := strings.ReplaceAll(originalString, "\n", " ")
|
||||
newString = strings.ReplaceAll(newString, "\t", " ")
|
||||
newString = strings.ReplaceAll(newString, "\"", "")
|
||||
mlog.Debug(newString)
|
||||
}
|
||||
|
||||
func NewSqlSupplier(settings model.SqlSettings, metrics einterfaces.MetricsInterface) *SqlSupplier {
|
||||
supplier := &SqlSupplier{
|
||||
rrCounter: 0,
|
||||
@@ -248,7 +257,7 @@ func setupConnection(con_type string, dataSource string, settings *model.SqlSett
|
||||
}
|
||||
|
||||
if settings.Trace != nil && *settings.Trace {
|
||||
dbmap.TraceOn("", sqltrace.New(os.Stdout, "sql-trace:", sqltrace.Lmicroseconds))
|
||||
dbmap.TraceOn("sql-trace:", &TraceOnAdapter{})
|
||||
}
|
||||
|
||||
return dbmap
|
||||
|
||||
Ссылка в новой задаче
Block a user