spacewander commented on a change in pull request #5831:
URL: https://github.com/apache/apisix/pull/5831#discussion_r786361041
##########
File path: apisix/plugins/file-logger.lua
##########
@@ -66,18 +66,18 @@ end
local function write_file_data(conf, log_message)
- local msg = core.json.encode(log_message) .. "\n"
+ local msg = core.json.encode(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)
else
- local ok, error = file:write(msg)
+ local ok, err = file:write(msg, '\n')
if not ok then
- core.log.error("failed to write file: ", conf.path, ", error info:
", error)
+ file:close()
Review comment:
We should close the file whether the writing success or not.
--
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]