monkeyDluffy6017 commented on code in PR #9619:
URL: https://github.com/apache/apisix/pull/9619#discussion_r1243199994


##########
apisix/plugins/log-rotate.lua:
##########
@@ -143,10 +157,18 @@ local function rename_file(log, date_str)
         core.log.info("file exist: ", new_file)
         return new_file
     end
-
-    local ok, err = os_rename(log.file, new_file)
+    local filename = log.file
+    -- create the file if it does not exist
+    local exists = lfs.attributes(filename, "mode") == "file"
+    if not exists then
+        local file = io_open(filename, "w")
+        if file then
+            file:close()
+        end
+    end

Review Comment:
   Is it necessay to add this check?
   The original logic looked fine,  `os.rename` would log when it failed and 
then skip



-- 
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: notifications-unsubscr...@apisix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to