Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
golangphone10
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhangjie
golangphone10
Commits
846375be
Commit
846375be
authored
Aug 09, 2021
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OEM电话机硬件服务器
parent
2a90d4d5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
30 deletions
+31
-30
main.go
main.go
+31
-30
No files found.
main.go
View file @
846375be
...
...
@@ -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"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment