Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[module] do not print warnings if module was loaded #415

Merged
merged 1 commit into from
Sep 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- `THREESCALE\_DEPLOYMENT\_ENV` defaults to `production` [PR #406](https://github.com/3scale/apicast/pull/406)
- OIDC is now used based on settings on the API Manager [PR #405](https://github.com/3scale/apicast/pull/405)
- No limit on body size from the client sent to the server [PR #410](https://github.com/3scale/apicast/pull/410)
- Print module loading errors only when it failed to load [PR #415](https://github.com/3scale/apicast/pull/415)

## [3.1.0-beta2] - 2017-08-21

Expand Down
6 changes: 5 additions & 1 deletion apicast/src/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,25 @@ local type = type
local env = require 'resty.env'

local function error_message(error)
ngx.log(ngx.WARN, error)
ngx.log(ngx.DEBUG, error)
return error
end

local prequire = function(file)
local ok, ret = xpcall(require, error_message, file)
local prev

if not ok and ret then
prev = ret
-- dofile can load absolute paths, require can't
ok, ret = xpcall(dofile, error_message, file)
end

if not ok and ret then
if type(ret) == 'userdata' then
ngx.log(ngx.WARN, 'cyclic require detected: ', debug.traceback())
elseif prev then
ngx.log(ngx.WARN, prev)
end
return false, ret
end
Expand Down