spacewander commented on a change in pull request #5831:
URL: https://github.com/apache/apisix/pull/5831#discussion_r785684333
##########
File path: apisix/plugins/file-logger.lua
##########
@@ -70,10 +70,15 @@ local function write_file_data(conf, log_message)
local file, err = io_open(conf.path, 'a+')
if not file then
- core.log.error("failed to open file: " .. conf.path .. ", error info:
" .. err)
+ core.log.error("failed to open file: ", conf.path, ", error info: ",
err)
else
- file:write(msg)
- file:flush()
+ local ok, error = file:write(msg)
Review comment:
```suggestion
local ok, err = file:write(msg)
```
and we need to close the file even failed to write.
BTW, we can use `file:write(msg, '\n')` to avoid `local msg =
core.json.encode(log_message) .. "\n"`
--
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]