From 2edf16077185fd5801ffa555c4066e8227e8f4be Mon Sep 17 00:00:00 2001 From: thefosk Date: Thu, 4 Jun 2015 18:06:19 -0700 Subject: [PATCH] fixing file log for multiple locations Former-commit-id: 53cbecbc1e745fd497fc26b8c4172c7df1eade7f --- kong/plugins/filelog/fd_util.lua | 10 +++++----- kong/plugins/filelog/log.lua | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) 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)