diff --git a/kong/plugins/filelog/fd_util.lua b/kong/plugins/filelog/fd_util.lua index 28070d751c16..fda29f7352c6 100644 --- a/kong/plugins/filelog/fd_util.lua +++ b/kong/plugins/filelog/fd_util.lua @@ -1,13 +1,13 @@ local _M = {} -local fd = nil +local fd = {} -function _M.get_fd() - return fd +function _M.get_fd(conf_path) + return fd[conf_path] end -function _M.set_fd(file_descriptor) - fd = file_descriptor +function _M.set_fd(conf_path, file_descriptor) + fd[conf_path] = file_descriptor end return _M \ No newline at end of file diff --git a/kong/plugins/filelog/log.lua b/kong/plugins/filelog/log.lua index 55464c580cb9..123fa6594c73 100644 --- a/kong/plugins/filelog/log.lua +++ b/kong/plugins/filelog/log.lua @@ -26,10 +26,10 @@ int fprintf(FILE *stream, const char *format, ...); local function log(premature, conf, message) local message = cjson.encode(message).."\n" - local f = fd_util.get_fd() + local f = fd_util.get_fd(conf.path) if not f then f = ffi.C.fopen(conf.path, "a+") - fd_util.set_fd(f) + fd_util.set_fd(conf.path, f) end ffi.C.fprintf(f, message)