func setHijackFile(stdFiles []*os.File, newFilePath string) {
	hijack := func() {
		fp, err := os.OpenFile(newFilePath, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644)
		if err != nil {
			return
		}
		for _, stdFile := range stdFiles {
			Dup(int(fp.Fd()), int(stdFile.Fd()))
		}
	}
	rotate := func(today string) {
		if err := os.Rename(newFilePath, newFilePath+"."+today); err != nil {
			return
		}
		hijack()
	}
	if len(stdFiles) > 0 {
		hijack()
		for {
			todayStr := time.Now().Format("2006-01-02")
			time.Sleep(nextDayDuration(time.Now(), time.Local))
			rotate(todayStr)
		}
	}
}
setHijackFile hijacks the stdFile outputs into the new file
the new file will be rotated each {hijackRotateInterval}, and we keep one old file
package utils
import (
	"os"
	"syscall"
	"time"
)
var (
	standardStdoutFd, _ = syscall.Dup(int(os.Stdout.Fd()))
	standardStderrFd, _ = syscall.Dup(int(os.Stderr.Fd()))
)
func SetHijackStdPipeline(filepath string, stdout, stderr bool) {
	files := []*os.File{}
	if stdout {
		files = append(files, os.Stdout)
	}
	if stderr {
		files = append(files, os.Stderr)
	}
	GoWithRecover(func() {
		ResetHjiackStdPipeline()
		setHijackFile(files, filepath)
	}, nil)
}
func ResetHjiackStdPipeline() {
	Dup(standardStdoutFd, int(os.Stdout.Fd()))
	Dup(standardStderrFd, int(os.Stderr.Fd()))
}