change: resty: print() is now identical to ngx.say(), which is more in line with the std "print" function. thanks Michal Cichra for the original patch in #65.

This commit is contained in:
Yichun Zhang (agentzh) 2014-09-10 13:29:39 -07:00
parent 07913609c6
commit b2cc655554
1 changed files with 12 additions and 3 deletions

View File

@ -178,13 +178,22 @@ $lua_package_path_config
return concat(dst)
end
print = function (...)
local function output(...)
local args = {...}
return stdout:write(expand_table(args, true))
end
ngx.print = print
ngx.say = function (...) local ok, err = print(...) if ok then return print("\\\\n") end return ok, err end
ngx.print = output
ngx.say = function (...)
local ok, err = output(...)
if ok then
return output("\\\\n")
end
return ok, err
end
print = ngx.say
ngx.flush = function (...) return stdout:flush() end
-- we cannot close stdout here due to a bug in Lua:
ngx.eof = function (...) return true end