mirror of https://github.com/1Panel-dev/1Panel
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.
21 lines
334 B
21 lines
334 B
package log
|
|
|
|
import (
|
|
"os"
|
|
"runtime"
|
|
"syscall"
|
|
)
|
|
|
|
var stdErrFileHandler *os.File
|
|
|
|
func dupWrite(file *os.File) error {
|
|
stdErrFileHandler = file
|
|
if err := syscall.Dup3(int(file.Fd()), int(os.Stderr.Fd()), 0); err != nil {
|
|
return err
|
|
}
|
|
runtime.SetFinalizer(stdErrFileHandler, func(fd *os.File) {
|
|
fd.Close()
|
|
})
|
|
return nil
|
|
}
|