]> Cypherpunks.ru repositories - nncp.git/blobdiff - src/log.go
Logging to opened file descriptor
[nncp.git] / src / log.go
index 7bb59a3b97cf798e5c35c01d0c76c19154445ba6..9a8d2e7505b7fc4b5eecdeb77d4d2b49dbab12dd 100644 (file)
@@ -27,6 +27,10 @@ import (
        "golang.org/x/sys/unix"
 )
 
+const LogFdPrefix = "FD:"
+
+var LogFd *os.File
+
 type LE struct {
        K string
        V interface{}
@@ -64,6 +68,10 @@ func (les LEs) Rec() string {
 }
 
 func (ctx *Ctx) Log(rec string) {
+       if LogFd != nil {
+               LogFd.WriteString(rec)
+               return
+       }
        fdLock, err := os.OpenFile(
                ctx.LogPath+".lock",
                os.O_CREATE|os.O_WRONLY,