现代化、开源的 Linux 服务器运维管理面板。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

20 lines
342 B

package log
import (
"golang.org/x/sys/unix"
"os"
"runtime"
)
var stdErrFileHandler *os.File
func dupWrite(file *os.File) error {
stdErrFileHandler = file
if err := unix.Dup2(int(file.Fd()), int(os.Stderr.Fd())); err != nil {
return err
}
runtime.SetFinalizer(stdErrFileHandler, func(fd *os.File) {
fd.Close()
})
return nil
}