mirror of
https://gitee.com/fit2cloud-feizhiyun/1Panel.git
synced 2024-12-05 05:19:08 +08:00
21 lines
331 B
Go
21 lines
331 B
Go
|
package log
|
||
|
|
||
|
import (
|
||
|
"os"
|
||
|
"runtime"
|
||
|
"syscall"
|
||
|
)
|
||
|
|
||
|
var stdErrFileHandler *os.File
|
||
|
|
||
|
func dupWrite(file *os.File) error {
|
||
|
stdErrFileHandler = file
|
||
|
if err := syscall.Dup2(int(file.Fd()), int(os.Stderr.Fd())); err != nil {
|
||
|
return err
|
||
|
}
|
||
|
runtime.SetFinalizer(stdErrFileHandler, func(fd *os.File) {
|
||
|
fd.Close()
|
||
|
})
|
||
|
return nil
|
||
|
}
|