From a6aa8fe4c8b164997c05455b555a149b82a54dba Mon Sep 17 00:00:00 2001 From: postmannen Date: Tue, 13 Apr 2021 13:25:44 +0200 Subject: [PATCH] added O_SYNC to log file opening --- process.go | 4 ++-- subscriber_method_types.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/process.go b/process.go index 75b7c4f..e187715 100644 --- a/process.go +++ b/process.go @@ -319,7 +319,7 @@ func (p process) subscriberHandler(natsConn *nats.Conn, thisNode string, msg *na out, err = mh.handler(p, message, thisNode) if err != nil { - er := fmt.Errorf("error: subscriberHandler: failed to execute event: %v", err) + er := fmt.Errorf("error: subscriberHandler: handler method failed: %v", err) sendErrorLogMessage(p.toRingbufferCh, node(thisNode), er) } } else { @@ -353,7 +353,7 @@ func (p process) subscriberHandler(natsConn *nats.Conn, thisNode string, msg *na _, err := mf.handler(p, message, thisNode) if err != nil { - er := fmt.Errorf("error: subscriberHandler: failed to execute event: %v", err) + er := fmt.Errorf("error: subscriberHandler: handler method failed: %v", err) sendErrorLogMessage(p.toRingbufferCh, node(thisNode), er) } } else { diff --git a/subscriber_method_types.go b/subscriber_method_types.go index af3fd60..fe9e6de 100644 --- a/subscriber_method_types.go +++ b/subscriber_method_types.go @@ -454,7 +454,7 @@ func (m methodREQTextToLogFile) handler(proc process, message Message, node stri // Open file and write data. file := filepath.Join(folderTree, fileName) - f, err := os.OpenFile(file, os.O_APPEND|os.O_RDWR|os.O_CREATE, os.ModeAppend) + f, err := os.OpenFile(file, os.O_APPEND|os.O_RDWR|os.O_CREATE|os.O_SYNC, os.ModeAppend) if err != nil { log.Printf("error: methodEventTextLogging.handler: failed to open file: %v\n", err) return nil, err