mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-17 22:25:29 +01:00
🎨 增加 kernel.log https://github.com/siyuan-note/siyuan/issues/7789
This commit is contained in:
parent
f534675464
commit
a85c61d3c1
7 changed files with 57 additions and 39 deletions
|
|
@ -48,7 +48,7 @@ require (
|
|||
github.com/siyuan-note/eventbus v0.0.0-20230216103454-41885eac6c2b
|
||||
github.com/siyuan-note/filelock v0.0.0-20230321113304-79a32917cc9f
|
||||
github.com/siyuan-note/httpclient v0.0.0-20230309131049-f703795de6bc
|
||||
github.com/siyuan-note/logging v0.0.0-20230319012246-6224f958f554
|
||||
github.com/siyuan-note/logging v0.0.0-20230327034340-a7bed1fff2fe
|
||||
github.com/siyuan-note/riff v0.0.0-20230224144841-cfbe0748ddb7
|
||||
github.com/steambap/captcha v1.4.1
|
||||
github.com/studio-b12/gowebdav v0.0.0-20230203202212-3282f94193f2
|
||||
|
|
|
|||
|
|
@ -293,6 +293,10 @@ github.com/siyuan-note/httpclient v0.0.0-20230309131049-f703795de6bc h1:MX2cPWpn
|
|||
github.com/siyuan-note/httpclient v0.0.0-20230309131049-f703795de6bc/go.mod h1:WDO42mUVRnkk8M4AhZ4oakZ5jnghulP0c8NFCrrFWG4=
|
||||
github.com/siyuan-note/logging v0.0.0-20230319012246-6224f958f554 h1:uaLbecIT6G7jFQUscXSzIxi/hDVSfzZccMCl8Lzqqn0=
|
||||
github.com/siyuan-note/logging v0.0.0-20230319012246-6224f958f554/go.mod h1:6mRFtAAvYPn3cDzqvyv+t8BVPGqpONDMMb5ywOhY1D4=
|
||||
github.com/siyuan-note/logging v0.0.0-20230327031937-fad01e626ac2 h1:RuByEVw3s+R4ch/n1Wd5uBn0Gd/PDqNae2QoYi/Q+vQ=
|
||||
github.com/siyuan-note/logging v0.0.0-20230327031937-fad01e626ac2/go.mod h1:6mRFtAAvYPn3cDzqvyv+t8BVPGqpONDMMb5ywOhY1D4=
|
||||
github.com/siyuan-note/logging v0.0.0-20230327034340-a7bed1fff2fe h1:QmBB+8HVbjxXzVUdAiysYaClEAaREcxeZt6kvHcrFUc=
|
||||
github.com/siyuan-note/logging v0.0.0-20230327034340-a7bed1fff2fe/go.mod h1:6mRFtAAvYPn3cDzqvyv+t8BVPGqpONDMMb5ywOhY1D4=
|
||||
github.com/siyuan-note/riff v0.0.0-20230224144841-cfbe0748ddb7 h1:Kr8hhMhr6v+U24TMDCP5WdP4dWrXm5maar+TycTZs9I=
|
||||
github.com/siyuan-note/riff v0.0.0-20230224144841-cfbe0748ddb7/go.mod h1:XJtLlKCr8cZE+lzykM4edHHih92M9M50UNw/nDLYRN8=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
|
||||
|
|
|
|||
|
|
@ -174,14 +174,23 @@ func ExportSystemLog() (zipPath string) {
|
|||
logging.LogErrorf("copy app log from [%s] to [%s] failed: %s", err, appLog, to)
|
||||
}
|
||||
}
|
||||
kernelLog := filepath.Join(util.TempDir, "siyuan.log")
|
||||
|
||||
kernelLog := filepath.Join(util.HomeDir, ".config", "siyuan", "kernel.log")
|
||||
if gulu.File.IsExist(kernelLog) {
|
||||
to := filepath.Join(exportFolder, "siyuan.log")
|
||||
to := filepath.Join(exportFolder, "kernel.log")
|
||||
if err := gulu.File.CopyFile(kernelLog, to); nil != err {
|
||||
logging.LogErrorf("copy kernel log from [%s] to [%s] failed: %s", err, kernelLog, to)
|
||||
}
|
||||
}
|
||||
|
||||
siyuanLog := filepath.Join(util.TempDir, "siyuan.log")
|
||||
if gulu.File.IsExist(siyuanLog) {
|
||||
to := filepath.Join(exportFolder, "siyuan.log")
|
||||
if err := gulu.File.CopyFile(siyuanLog, to); nil != err {
|
||||
logging.LogErrorf("copy kernel log from [%s] to [%s] failed: %s", err, siyuanLog, to)
|
||||
}
|
||||
}
|
||||
|
||||
zipPath = exportFolder + ".zip"
|
||||
zip, err := gulu.Zip.Create(zipPath)
|
||||
if nil != err {
|
||||
|
|
|
|||
|
|
@ -244,12 +244,11 @@ func checkFileSysStatus() {
|
|||
}
|
||||
|
||||
func IsCloudDrivePath(workspaceAbsPath string) bool {
|
||||
absPathLower := strings.ToLower(workspaceAbsPath)
|
||||
if isICloudPath(absPathLower) {
|
||||
if isICloudPath(workspaceAbsPath) {
|
||||
return true
|
||||
}
|
||||
|
||||
if isKnownCloudDrivePath(absPathLower) {
|
||||
if isKnownCloudDrivePath(workspaceAbsPath) {
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
@ -260,17 +259,20 @@ func IsCloudDrivePath(workspaceAbsPath string) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func isKnownCloudDrivePath(workspaceAbsPathLower string) bool {
|
||||
func isKnownCloudDrivePath(workspaceAbsPath string) bool {
|
||||
workspaceAbsPathLower := strings.ToLower(workspaceAbsPath)
|
||||
return strings.Contains(workspaceAbsPathLower, "onedrive") || strings.Contains(workspaceAbsPathLower, "dropbox") ||
|
||||
strings.Contains(workspaceAbsPathLower, "google drive") || strings.Contains(workspaceAbsPathLower, "pcloud") ||
|
||||
strings.Contains(workspaceAbsPathLower, "坚果云")
|
||||
}
|
||||
|
||||
func isICloudPath(workspaceAbsPathLower string) (ret bool) {
|
||||
func isICloudPath(workspaceAbsPath string) (ret bool) {
|
||||
if !gulu.OS.IsDarwin() {
|
||||
return false
|
||||
}
|
||||
|
||||
workspaceAbsPathLower := strings.ToLower(workspaceAbsPath)
|
||||
|
||||
// macOS 端对工作空间放置在 iCloud 路径下做检查 https://github.com/siyuan-note/siyuan/issues/7747
|
||||
iCloudRoot := filepath.Join(HomeDir, "Library", "Mobile Documents")
|
||||
WalkWithSymlinks(iCloudRoot, func(path string, info os.FileInfo, err error) error {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import (
|
|||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"math/rand"
|
||||
"mime"
|
||||
"os"
|
||||
|
|
@ -186,10 +185,12 @@ var (
|
|||
func initWorkspaceDir(workspaceArg string) {
|
||||
userHomeConfDir := filepath.Join(HomeDir, ".config", "siyuan")
|
||||
workspaceConf := filepath.Join(userHomeConfDir, "workspace.json")
|
||||
logging.SetLogPath(filepath.Join(userHomeConfDir, "kernel.log"))
|
||||
|
||||
if !gulu.File.IsExist(workspaceConf) {
|
||||
if err := os.MkdirAll(userHomeConfDir, 0755); nil != err && !os.IsExist(err) {
|
||||
log.Printf("create user home conf folder [%s] failed: %s", userHomeConfDir, err)
|
||||
os.Exit(logging.ExitCodeCreateConfDirErr)
|
||||
logging.LogErrorf("create user home conf folder [%s] failed: %s", userHomeConfDir, err)
|
||||
os.Exit(logging.ExitCodeInitWorkspaceErr)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -201,8 +202,8 @@ func initWorkspaceDir(workspaceArg string) {
|
|||
}
|
||||
}
|
||||
if err := os.MkdirAll(defaultWorkspaceDir, 0755); nil != err && !os.IsExist(err) {
|
||||
log.Printf("create default workspace folder [%s] failed: %s", defaultWorkspaceDir, err)
|
||||
os.Exit(logging.ExitCodeCreateWorkspaceDirErr)
|
||||
logging.LogErrorf("create default workspace folder [%s] failed: %s", defaultWorkspaceDir, err)
|
||||
os.Exit(logging.ExitCodeInitWorkspaceErr)
|
||||
}
|
||||
|
||||
var workspacePaths []string
|
||||
|
|
@ -226,13 +227,14 @@ func initWorkspaceDir(workspaceArg string) {
|
|||
}
|
||||
|
||||
if !gulu.File.IsDir(WorkspaceDir) {
|
||||
log.Printf("use the default workspace [%s] since the specified workspace [%s] is not a dir", WorkspaceDir, defaultWorkspaceDir)
|
||||
logging.LogWarnf("use the default workspace [%s] since the specified workspace [%s] is not a dir", WorkspaceDir, defaultWorkspaceDir)
|
||||
WorkspaceDir = defaultWorkspaceDir
|
||||
}
|
||||
workspacePaths = append(workspacePaths, WorkspaceDir)
|
||||
|
||||
if err := WriteWorkspacePaths(workspacePaths); nil != err {
|
||||
log.Fatalf("write workspace conf [%s] failed: %s", workspaceConf, err)
|
||||
logging.LogErrorf("write workspace conf [%s] failed: %s", workspaceConf, err)
|
||||
os.Exit(logging.ExitCodeInitWorkspaceErr)
|
||||
}
|
||||
|
||||
ConfDir = filepath.Join(WorkspaceDir, "conf")
|
||||
|
|
@ -243,7 +245,8 @@ func initWorkspaceDir(workspaceArg string) {
|
|||
osTmpDir := filepath.Join(TempDir, "os")
|
||||
os.RemoveAll(osTmpDir)
|
||||
if err := os.MkdirAll(osTmpDir, 0755); nil != err {
|
||||
log.Fatalf("create os tmp dir [%s] failed: %s", osTmpDir, err)
|
||||
logging.LogErrorf("create os tmp dir [%s] failed: %s", osTmpDir, err)
|
||||
os.Exit(logging.ExitCodeInitWorkspaceErr)
|
||||
}
|
||||
os.RemoveAll(filepath.Join(TempDir, "repo"))
|
||||
os.Setenv("TMPDIR", osTmpDir)
|
||||
|
|
@ -327,33 +330,33 @@ const (
|
|||
|
||||
func initPathDir() {
|
||||
if err := os.MkdirAll(ConfDir, 0755); nil != err && !os.IsExist(err) {
|
||||
log.Fatalf("create conf folder [%s] failed: %s", ConfDir, err)
|
||||
logging.LogFatalf(logging.ExitCodeInitWorkspaceErr, "create conf folder [%s] failed: %s", ConfDir, err)
|
||||
}
|
||||
if err := os.MkdirAll(DataDir, 0755); nil != err && !os.IsExist(err) {
|
||||
log.Fatalf("create data folder [%s] failed: %s", DataDir, err)
|
||||
logging.LogFatalf(logging.ExitCodeInitWorkspaceErr, "create data folder [%s] failed: %s", DataDir, err)
|
||||
}
|
||||
if err := os.MkdirAll(TempDir, 0755); nil != err && !os.IsExist(err) {
|
||||
log.Fatalf("create temp folder [%s] failed: %s", TempDir, err)
|
||||
logging.LogFatalf(logging.ExitCodeInitWorkspaceErr, "create temp folder [%s] failed: %s", TempDir, err)
|
||||
}
|
||||
|
||||
assets := filepath.Join(DataDir, "assets")
|
||||
if err := os.MkdirAll(assets, 0755); nil != err && !os.IsExist(err) {
|
||||
log.Fatalf("create data assets folder [%s] failed: %s", assets, err)
|
||||
logging.LogFatalf(logging.ExitCodeInitWorkspaceErr, "create data assets folder [%s] failed: %s", assets, err)
|
||||
}
|
||||
|
||||
templates := filepath.Join(DataDir, "templates")
|
||||
if err := os.MkdirAll(templates, 0755); nil != err && !os.IsExist(err) {
|
||||
log.Fatalf("create data templates folder [%s] failed: %s", templates, err)
|
||||
logging.LogFatalf(logging.ExitCodeInitWorkspaceErr, "create data templates folder [%s] failed: %s", templates, err)
|
||||
}
|
||||
|
||||
widgets := filepath.Join(DataDir, "widgets")
|
||||
if err := os.MkdirAll(widgets, 0755); nil != err && !os.IsExist(err) {
|
||||
log.Fatalf("create data widgets folder [%s] failed: %s", widgets, err)
|
||||
logging.LogFatalf(logging.ExitCodeInitWorkspaceErr, "create data widgets folder [%s] failed: %s", widgets, err)
|
||||
}
|
||||
|
||||
emojis := filepath.Join(DataDir, "emojis")
|
||||
if err := os.MkdirAll(emojis, 0755); nil != err && !os.IsExist(err) {
|
||||
log.Fatalf("create data emojis folder [%s] failed: %s", widgets, err)
|
||||
logging.LogFatalf(logging.ExitCodeInitWorkspaceErr, "create data emojis folder [%s] failed: %s", widgets, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
package util
|
||||
|
||||
import (
|
||||
"log"
|
||||
"math/rand"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
|
@ -43,18 +42,20 @@ func BootMobile(container, appDir, workspaceBaseDir, lang string) {
|
|||
WorkingDir = filepath.Join(appDir, "app")
|
||||
HomeDir = filepath.Join(workspaceBaseDir, "home")
|
||||
userHomeConfDir := filepath.Join(HomeDir, ".config", "siyuan")
|
||||
logging.SetLogPath(filepath.Join(userHomeConfDir, "kernel.log"))
|
||||
|
||||
if !gulu.File.IsExist(userHomeConfDir) {
|
||||
if err := os.MkdirAll(userHomeConfDir, 0755); nil != err && !os.IsExist(err) {
|
||||
log.Printf("create user home conf folder [%s] failed: %s", userHomeConfDir, err)
|
||||
os.Exit(logging.ExitCodeCreateConfDirErr)
|
||||
logging.LogErrorf("create user home conf folder [%s] failed: %s", userHomeConfDir, err)
|
||||
os.Exit(logging.ExitCodeInitWorkspaceErr)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
defaultWorkspaceDir := filepath.Join(workspaceBaseDir, "siyuan")
|
||||
if err := os.MkdirAll(defaultWorkspaceDir, 0755); nil != err && !os.IsExist(err) {
|
||||
log.Printf("create default workspace folder [%s] failed: %s", defaultWorkspaceDir, err)
|
||||
os.Exit(logging.ExitCodeCreateWorkspaceDirErr)
|
||||
logging.LogErrorf("create default workspace folder [%s] failed: %s", defaultWorkspaceDir, err)
|
||||
os.Exit(logging.ExitCodeInitWorkspaceErr)
|
||||
}
|
||||
|
||||
initWorkspaceDirMobile(workspaceBaseDir)
|
||||
|
|
@ -69,7 +70,7 @@ func initWorkspaceDirMobile(workspaceBaseDir string) {
|
|||
if gulu.File.IsDir(workspaceBaseDir) {
|
||||
entries, err := os.ReadDir(workspaceBaseDir)
|
||||
if nil != err {
|
||||
log.Printf("read workspace dir [%s] failed: %s", workspaceBaseDir, err)
|
||||
logging.LogErrorf("read workspace dir [%s] failed: %s", workspaceBaseDir, err)
|
||||
} else {
|
||||
// 旧版 iOS 端会在 workspaceBaseDir 下直接创建工作空间,这里需要将数据迁移到 workspaceBaseDir/siyuan/ 文件夹下
|
||||
var oldConf, oldData, oldTemp bool
|
||||
|
|
@ -96,9 +97,9 @@ func initWorkspaceDirMobile(workspaceBaseDir string) {
|
|||
from := filepath.Join(workspaceBaseDir, entry.Name())
|
||||
to := filepath.Join(workspaceBaseDir, "siyuan", entry.Name())
|
||||
if err = os.Rename(from, to); nil != err {
|
||||
log.Printf("move workspace dir [%s] failed: %s", workspaceBaseDir, err)
|
||||
logging.LogErrorf("move workspace dir [%s] failed: %s", workspaceBaseDir, err)
|
||||
} else {
|
||||
log.Printf("moved workspace dir [fomr=%s, to=%s]", from, to)
|
||||
logging.LogInfof("moved workspace dir [fomr=%s, to=%s]", from, to)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -116,7 +117,7 @@ func initWorkspaceDirMobile(workspaceBaseDir string) {
|
|||
if !gulu.File.IsExist(workspaceConf) {
|
||||
WorkspaceDir = defaultWorkspaceDir
|
||||
if !gulu.File.IsDir(WorkspaceDir) {
|
||||
log.Printf("use the default workspace [%s] since the specified workspace [%s] is not a dir", WorkspaceDir, defaultWorkspaceDir)
|
||||
logging.LogWarnf("use the default workspace [%s] since the specified workspace [%s] is not a dir", WorkspaceDir, defaultWorkspaceDir)
|
||||
WorkspaceDir = defaultWorkspaceDir
|
||||
}
|
||||
workspacePaths = append(workspacePaths, WorkspaceDir)
|
||||
|
|
@ -125,7 +126,7 @@ func initWorkspaceDirMobile(workspaceBaseDir string) {
|
|||
if 0 < len(workspacePaths) {
|
||||
WorkspaceDir = workspacePaths[len(workspacePaths)-1]
|
||||
if !gulu.File.IsDir(WorkspaceDir) {
|
||||
log.Printf("use the default workspace [%s] since the specified workspace [%s] is not a dir", defaultWorkspaceDir, WorkspaceDir)
|
||||
logging.LogWarnf("use the default workspace [%s] since the specified workspace [%s] is not a dir", defaultWorkspaceDir, WorkspaceDir)
|
||||
WorkspaceDir = defaultWorkspaceDir
|
||||
}
|
||||
workspacePaths[len(workspacePaths)-1] = WorkspaceDir
|
||||
|
|
@ -136,7 +137,8 @@ func initWorkspaceDirMobile(workspaceBaseDir string) {
|
|||
}
|
||||
|
||||
if err := WriteWorkspacePaths(workspacePaths); nil != err {
|
||||
log.Fatalf("write workspace conf [%s] failed: %s", workspaceConf, err)
|
||||
logging.LogErrorf("write workspace conf [%s] failed: %s", workspaceConf, err)
|
||||
os.Exit(logging.ExitCodeInitWorkspaceErr)
|
||||
}
|
||||
|
||||
ConfDir = filepath.Join(WorkspaceDir, "conf")
|
||||
|
|
@ -147,7 +149,8 @@ func initWorkspaceDirMobile(workspaceBaseDir string) {
|
|||
osTmpDir := filepath.Join(TempDir, "os")
|
||||
os.RemoveAll(osTmpDir)
|
||||
if err := os.MkdirAll(osTmpDir, 0755); nil != err {
|
||||
log.Fatalf("create os tmp dir [%s] failed: %s", osTmpDir, err)
|
||||
logging.LogErrorf("create os tmp dir [%s] failed: %s", osTmpDir, err)
|
||||
os.Exit(logging.ExitCodeInitWorkspaceErr)
|
||||
}
|
||||
os.RemoveAll(filepath.Join(TempDir, "repo"))
|
||||
os.Setenv("TMPDIR", osTmpDir)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue