Files
picoclaw/pkg/logger/panic_unix.go
T
Cytown df17684dd4 implement panic log for gateway and launcher
add file logger to gateway

ref issue: #1734

Signed-off-by: Cytown <cytown@gmail.com>
2026-03-23 15:40:30 +08:00

22 lines
444 B
Go

//go:build !windows
// +build !windows
package logger
import (
"fmt"
"io"
"os"
)
func initPanicFile(panicFile string) io.WriteCloser {
file, err := os.OpenFile(panicFile, os.O_WRONLY|os.O_CREATE|os.O_APPEND|os.O_SYNC, 0o600)
if err != nil {
panic(fmt.Sprintf("error in open panic: %v", err))
}
if err = Dup2(int(file.Fd()), int(os.Stderr.Fd())); err != nil {
panic(fmt.Sprintf("error in syscall.Dup2: %v", err))
}
return file
}