mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 14:40:12 +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
|
|
@ -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