-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,21 @@ local cjson = require "cjson" | |
|
||
local _M = {} | ||
|
||
function _M.execute() | ||
ngx.log(ngx.INFO, cjson.encode(ngx.ctx.log_message)) | ||
-- Log to a file | ||
-- @param `premature` | ||
-- @param `conf` Configuration table, holds http endpoint details | ||
-- @param `message` Message to be logged | ||
local function log(premature, conf, message) | ||
local f = io.open(conf.path, "a+") | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
subnetmarco
Author
Member
|
||
f:write(cjson.encode(message).."\n") | ||
f:close() | ||
end | ||
|
||
function _M.execute(conf) | ||
local ok, err = ngx.timer.at(0, log, conf, ngx.ctx.log_message) | ||
if not ok then | ||
ngx.log(ngx.ERR, "[filelog] failed to create timer: ", err) | ||
end | ||
end | ||
|
||
return _M |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,18 @@ | ||
return {} -- No schema | ||
local IO = require "kong.tools.io" | ||
|
||
local function validate_file(value) | ||
local exists = IO.file_exists(value) | ||
if not os.execute("touch "..value) == 0 then | ||
return false, "Cannot create a file in the path specified. Make sure the path is valid, and Kong has the right permissions" | ||
end | ||
|
||
if not exists then | ||
os.remove(value) -- Remove the created file if it didn't exist before | ||
end | ||
|
||
return true | ||
end | ||
|
||
return { | ||
path = { required = true, type = "string", func = validate_file } | ||
} |
2 comments
on commit 148580e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please describe what the bug was in commit messages... Easier to write the Changelog after
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On multipart requests when a client sends a Expect: 100-continue
header, Kong stopped executing any subsequent phase.
Are you opening and closing the file on every request? I think that is extremely bad. I don't know exactly how nginx logs to the files on disk but very probably not by doing so