Commit 846375be by Administrator

OEM电话机硬件服务器

parent 2a90d4d5
...@@ -10,40 +10,41 @@ import ( ...@@ -10,40 +10,41 @@ import (
) )
//windows //windows
//var ( var (
// kernel32 = syscall.MustLoadDLL("kernel32.dll") kernel32 = syscall.MustLoadDLL("kernel32.dll")
// procSetStdHandle = kernel32.MustFindProc("SetStdHandle") procSetStdHandle = kernel32.MustFindProc("SetStdHandle")
//) )
//
//func setStdHandle(stdhandle int32, handle syscall.Handle) error { func setStdHandle(stdhandle int32, handle syscall.Handle) error {
// r0, _, e1 := syscall.Syscall(procSetStdHandle.Addr(), 2, uintptr(stdhandle), uintptr(handle), 0) r0, _, e1 := syscall.Syscall(procSetStdHandle.Addr(), 2, uintptr(stdhandle), uintptr(handle), 0)
// if r0 == 0 { if r0 == 0 {
// if e1 != 0 { if e1 != 0 {
// return error(e1) return error(e1)
// } }
// return syscall.EINVAL return syscall.EINVAL
// } }
// return nil return nil
//} }
//
//// redirectStderr to the file passed in
//func redirectStderrWindows(f *os.File) {
// err := setStdHandle(syscall.STD_ERROR_HANDLE, syscall.Handle(f.Fd()))
// if err != nil {
// logger.Log.Panic(err.Error())
// }
// // SetStdHandle does not affect prior references to stderr
// os.Stderr = f
//}
//windows end
func redirectStderrLinux(f *os.File) { // redirectStderr to the file passed in
err := syscall.Dup2(int(f.Fd()), int(os.Stderr.Fd())) func redirectStderrWindows(f *os.File) {
err := setStdHandle(syscall.STD_ERROR_HANDLE, syscall.Handle(f.Fd()))
if err != nil { if err != nil {
logger.Log.Panic(err.Error()) logger.Log.Panic(err.Error())
} }
// SetStdHandle does not affect prior references to stderr
os.Stderr = f
} }
//windows end
//func redirectStderrLinux(f *os.File) {
// err := syscall.Dup2(int(f.Fd()), int(os.Stderr.Fd()))
// if err != nil {
// logger.Log.Panic(err.Error())
// }
//}
func init() { func init() {
logger.InitLogger() logger.InitLogger()
f, err := os.OpenFile(jeffutil.LogPath+"panic.log", os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0755) f, err := os.OpenFile(jeffutil.LogPath+"panic.log", os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0755)
...@@ -51,8 +52,8 @@ func init() { ...@@ -51,8 +52,8 @@ func init() {
logger.Log.Panic(err.Error()) logger.Log.Panic(err.Error())
} }
//redirectStderrWindows(f) redirectStderrWindows(f)
redirectStderrLinux(f) // redirectStderrLinux(f)
} }
// dcfan50 "jeff_workstation_1/devproduct/dcfan50" // dcfan50 "jeff_workstation_1/devproduct/dcfan50"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment