🎨 记录操作系统平台

This commit is contained in:
Liang Ding 2023-02-10 21:39:24 +08:00
parent d316e4abc3
commit 235d940cad
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
7 changed files with 72 additions and 5 deletions

33
kernel/util/os.go Normal file
View file

@ -0,0 +1,33 @@
// SiYuan - Build Your Eternal Digital Garden
// Copyright (c) 2020-present, b3log.org
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//go:build !ios && !android
package util
import (
"github.com/shirou/gopsutil/v3/host"
"github.com/siyuan-note/logging"
)
func GetOSPlatform() (ret string) {
ret, _, _, err := host.PlatformInformation()
if nil != err {
logging.LogWarnf("get os platform failed: %s", err)
return
}
return
}

29
kernel/util/os_mobile.go Normal file
View file

@ -0,0 +1,29 @@
// SiYuan - Build Your Eternal Digital Garden
// Copyright (c) 2020-present, b3log.org
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//go:build ios || android
package util
func GetOSPlatform() (ret string) {
if ContainerIOS == Container {
return "iOS"
}
if ContainerAndroid == Container {
return "Android"
}
return
}

View file

@ -49,6 +49,7 @@ func logBootInfo() {
logging.LogInfof("kernel is booting:\n"+
" * ver [%s]\n"+
" * arch [%s]\n"+
" * os [%s] "+
" * pid [%d]\n"+
" * runtime mode [%s]\n"+
" * working directory [%s]\n"+
@ -56,7 +57,7 @@ func logBootInfo() {
" * container [%s]\n"+
" * database [ver=%s]\n"+
" * workspace directory [%s]",
Ver, runtime.GOARCH, os.Getpid(), Mode, WorkingDir, ReadOnly, Container, DatabaseVer, WorkspaceDir)
Ver, runtime.GOARCH, GetOSPlatform(), os.Getpid(), Mode, WorkingDir, ReadOnly, Container, DatabaseVer, WorkspaceDir)
}
func IsMutexLocked(m *sync.Mutex) bool {