]> Cypherpunks.ru repositories - nncp.git/blobdiff - src/lockdir.go
Logging refactoring, no centralized humanizer
[nncp.git] / src / lockdir.go
index 2e6ac204048ff360982392477337b3d0ea6e6516..2219d1bcfcd61643ada18a0df56557690d446990 100644 (file)
@@ -26,7 +26,6 @@ import (
 
 func (ctx *Ctx) LockDir(nodeId *NodeId, lockCtx string) (*os.File, error) {
        if err := ctx.ensureRxDir(nodeId); err != nil {
-               ctx.LogE("lockdir", LEs{}, err, "")
                return nil, err
        }
        lockPath := filepath.Join(ctx.Spool, nodeId.String(), lockCtx) + ".lock"
@@ -36,12 +35,16 @@ func (ctx *Ctx) LockDir(nodeId *NodeId, lockCtx string) (*os.File, error) {
                os.FileMode(0666),
        )
        if err != nil {
-               ctx.LogE("lockdir", LEs{{"path", lockPath}}, err, "")
+               ctx.LogE("lockdir-open", LEs{{"Path", lockPath}}, err, func(les LEs) string {
+                       return "Locking directory: opening %s" + lockPath
+               })
                return nil, err
        }
        err = unix.Flock(int(dirLock.Fd()), unix.LOCK_EX|unix.LOCK_NB)
        if err != nil {
-               ctx.LogE("lockdir", LEs{{"path", lockPath}}, err, "")
+               ctx.LogE("lockdir-flock", LEs{{"Path", lockPath}}, err, func(les LEs) string {
+                       return "Locking directory: locking %s" + lockPath
+               })
                dirLock.Close() // #nosec G104
                return nil, err
        }