mirror of
https://github.com/1Panel-dev/1Panel
synced 2024-11-23 16:39:24 +00:00
21 lines
334 B
Go
21 lines
334 B
Go
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
|
|
}
|