mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
♻️ 日志组件单独抽取项目 https://github.com/siyuan-note/siyuan/issues/5439
This commit is contained in:
parent
c8ea858976
commit
505b973c2d
70 changed files with 671 additions and 942 deletions
|
|
@ -27,6 +27,7 @@ import (
|
|||
|
||||
"github.com/88250/lute/parse"
|
||||
"github.com/emirpasic/gods/sets/hashset"
|
||||
"github.com/siyuan-note/logging"
|
||||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
|
|
@ -64,11 +65,11 @@ func WaitForWritingDatabase() {
|
|||
for i := 0; isWritingDatabase(); i++ {
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
if 200 < i && !printLog { // 10s 后打日志
|
||||
util.LogWarnf("database is writing: \n%s", util.ShortStack())
|
||||
logging.LogWarnf("database is writing: \n%s", logging.ShortStack())
|
||||
printLog = true
|
||||
}
|
||||
if 1200 < i && !lastPrintLog { // 60s 后打日志
|
||||
util.LogWarnf("database is still writing")
|
||||
logging.LogWarnf("database is still writing")
|
||||
lastPrintLog = true
|
||||
}
|
||||
}
|
||||
|
|
@ -102,7 +103,7 @@ func flushTreeQueue() {
|
|||
case "upsert":
|
||||
tree := op.upsertTree
|
||||
if err = upsertTree(tx, tree); nil != err {
|
||||
util.LogErrorf("upsert tree [%s] into database failed: %s", tree.Box+tree.Path, err)
|
||||
logging.LogErrorf("upsert tree [%s] into database failed: %s", tree.Box+tree.Path, err)
|
||||
}
|
||||
boxes.Add(op.upsertTree.Box)
|
||||
case "delete":
|
||||
|
|
@ -116,13 +117,13 @@ func flushTreeQueue() {
|
|||
updateRootContent(tx, path.Base(op.renameTreeNewHPath), op.renameTreeID)
|
||||
boxes.Add(op.renameTreeBox)
|
||||
default:
|
||||
util.LogErrorf("unknown operation [%s]", op.action)
|
||||
logging.LogErrorf("unknown operation [%s]", op.action)
|
||||
}
|
||||
}
|
||||
CommitTx(tx)
|
||||
elapsed := time.Now().Sub(start).Milliseconds()
|
||||
if 5000 < elapsed {
|
||||
util.LogInfof("op tx [%dms]", elapsed)
|
||||
logging.LogInfof("op tx [%dms]", elapsed)
|
||||
}
|
||||
|
||||
start = time.Now()
|
||||
|
|
@ -136,7 +137,7 @@ func flushTreeQueue() {
|
|||
CommitTx(tx)
|
||||
elapsed = time.Now().Sub(start).Milliseconds()
|
||||
if 1000 < elapsed {
|
||||
util.LogInfof("hash tx [%dms]", elapsed)
|
||||
logging.LogInfof("hash tx [%dms]", elapsed)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -219,7 +220,7 @@ func updateBoxHash(tx *sql.Tx, boxID string) {
|
|||
func boxChecksum(box string) (ret string) {
|
||||
rows, err := query("SELECT hash FROM blocks WHERE type = 'd' AND box = ? ORDER BY id DESC", box)
|
||||
if nil != err {
|
||||
util.LogErrorf("sql query failed: %s", err)
|
||||
logging.LogErrorf("sql query failed: %s", err)
|
||||
return
|
||||
}
|
||||
defer rows.Close()
|
||||
|
|
@ -227,7 +228,7 @@ func boxChecksum(box string) (ret string) {
|
|||
for rows.Next() {
|
||||
var hash string
|
||||
if err = rows.Scan(&hash); nil != err {
|
||||
util.LogErrorf("query scan field failed: %s", err)
|
||||
logging.LogErrorf("query scan field failed: %s", err)
|
||||
return
|
||||
}
|
||||
buf.WriteString(hash)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue