Skip to content

Commit

Permalink
fixing file log for multiple locations
Browse files Browse the repository at this point in the history
  • Loading branch information
subnetmarco committed Jun 5, 2015
1 parent aa5930a commit 486f374
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 486f374

Please sign in to comment.