"bytes"
"fmt"
"os"
+ "sync"
"time"
"go.cypherpunks.ru/recfile"
"golang.org/x/sys/unix"
)
+const LogFdPrefix = "FD:"
+
+var (
+ LogFd *os.File
+ LogFdLock sync.Mutex
+)
+
type LE struct {
K string
V interface{}
}
func (ctx *Ctx) Log(rec string) {
+ if LogFd != nil {
+ LogFdLock.Lock()
+ LogFd.WriteString(rec)
+ LogFdLock.Unlock()
+ return
+ }
fdLock, err := os.OpenFile(
ctx.LogPath+".lock",
os.O_CREATE|os.O_WRONLY,
fmt.Fprintln(os.Stderr, "Can not open log:", err)
return
}
- fd.WriteString(rec) // #nosec G104
- fd.Close() // #nosec G104
+ fd.WriteString(rec)
+ fd.Close()
}
func (ctx *Ctx) LogD(who string, les LEs, msg func(LEs) string) {