Skip to content

Commit

Permalink
fixing file log for multiple locations
Browse files Browse the repository at this point in the history
Former-commit-id: 53cbecbc1e745fd497fc26b8c4172c7df1eade7f
  • Loading branch information
subnetmarco committed Jun 5, 2015
1 parent 47d9ad5 commit 2edf160
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions kong/plugins/filelog/fd_util.lua
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions kong/plugins/filelog/log.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2edf160

Please sign in to comment.