Skip to content

Commit

Permalink
Log with ngx.log only if in OpenResty environment
Browse files Browse the repository at this point in the history
  • Loading branch information
subnetmarco committed Jul 14, 2015
1 parent 2c3adb0 commit bcf3559
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/resty/iputils.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
local ipairs, unpack, tonumber, tostring, type = ipairs, unpack, tonumber, tostring, type
local ngx = ngx
local ngx_log = ngx.log
local ngx_ERR = ngx.ERR
local bit = require("bit")
local tobit = bit.tobit
local lshift = bit.lshift
Expand Down Expand Up @@ -151,7 +148,9 @@ local function parse_cidrs(cidrs)
for _,cidr in ipairs(cidrs) do
local lower, upper = parse_cidr(cidr)
if not lower then
ngx_log(ngx_ERR, "Error parsing '", cidr, "': ", upper)
if ngx then
ngx.log(ngx.ERR, "Error parsing '", cidr, "': ", upper)
end
else
out[i] = {lower, upper}
i = i+1
Expand Down

0 comments on commit bcf3559

Please sign in to comment.