bzp2010 commented on code in PR #7884:
URL: https://github.com/apache/apisix/pull/7884#discussion_r965557052


##########
apisix/plugins/file-logger.lua:
##########
@@ -116,11 +119,16 @@ local function write_file_data(conf, log_message)
     if not file then
         core.log.error("failed to open file: ", conf.path, ", error info: ", 
err)
     else
-        local ok, err = file:write(msg, '\n')
+        -- file:write(msg, "\n") will call fwrite several times
+        -- which will cause problem with the log output
+        -- it should be atomic
+        msg = msg .. "\n"
+        local ok, err = file:write(msg)
         if not ok then
             core.log.error("failed to write file: ", conf.path, ", error info: 
", err)
         else
-            file:flush()
+            -- No buffering model don't need flush, write to file directly
+            -- file:flush()

Review Comment:
   If they are no longer needed, do we need to delete it? BTW, the code lint 
point this too, there is an empty if branch.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to