Commit 846375be by Administrator

OEM电话机硬件服务器

parent 2a90d4d5
......@@ -10,40 +10,41 @@ import (
)
//windows
//var (
// kernel32 = syscall.MustLoadDLL("kernel32.dll")
// procSetStdHandle = kernel32.MustFindProc("SetStdHandle")
//)
//
//func setStdHandle(stdhandle int32, handle syscall.Handle) error {
// r0, _, e1 := syscall.Syscall(procSetStdHandle.Addr(), 2, uintptr(stdhandle), uintptr(handle), 0)
// if r0 == 0 {
// if e1 != 0 {
// return error(e1)
// }
// return syscall.EINVAL
// }
// 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
var (
kernel32 = syscall.MustLoadDLL("kernel32.dll")
procSetStdHandle = kernel32.MustFindProc("SetStdHandle")
)
func setStdHandle(stdhandle int32, handle syscall.Handle) error {
r0, _, e1 := syscall.Syscall(procSetStdHandle.Addr(), 2, uintptr(stdhandle), uintptr(handle), 0)
if r0 == 0 {
if e1 != 0 {
return error(e1)
}
return syscall.EINVAL
}
return nil
}
func redirectStderrLinux(f *os.File) {
err := syscall.Dup2(int(f.Fd()), int(os.Stderr.Fd()))
// 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) {
// err := syscall.Dup2(int(f.Fd()), int(os.Stderr.Fd()))
// if err != nil {
// logger.Log.Panic(err.Error())
// }
//}
func init() {
logger.InitLogger()
f, err := os.OpenFile(jeffutil.LogPath+"panic.log", os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0755)
......@@ -51,8 +52,8 @@ func init() {
logger.Log.Panic(err.Error())
}
//redirectStderrWindows(f)
redirectStderrLinux(f)
redirectStderrWindows(f)
// redirectStderrLinux(f)
}
// 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