Skip to content

Commit

Permalink
THREESCALE-10894 removing unnecessary tostring
Browse files Browse the repository at this point in the history
  • Loading branch information
MStokluska committed Sep 30, 2024
1 parent f8ed445 commit 1e2b984
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
9 changes: 2 additions & 7 deletions gateway/src/apicast/configuration.lua
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,8 @@ function _M.filter_services(services, subset)
end

-- Log all filtered services in a single log
if #filtered_services > 0 then
local filtered_services_str = {}
for _, service_id in ipairs(filtered_services) do
table.insert(filtered_services_str, tostring(service_id))
end

ngx.log(ngx.WARN, "filtering out services: " .. table.concat(filtered_services_str, ", "))
if #filtered_services > 0 then
ngx.log(ngx.WARN, "filtering out services: ", table.concat(filtered_services, ", "))
end

return selected_services
Expand Down
11 changes: 6 additions & 5 deletions spec/configuration_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ local configuration = require 'apicast.configuration'
local env = require 'resty.env'
local captured_logs = {}

local function capture_log(level, message)
print("Captured log level: ", level, " message: ", message)
table.insert(captured_logs, {level = level, message = message})
local function capture_log(level, ...)
local message_parts = {...} -- Capture all message parts
local full_message = table.concat(message_parts, "") -- Concatenate the parts into a full string
table.insert(captured_logs, {level = level, message = full_message})
end

describe('Configuration object', function()
Expand Down Expand Up @@ -156,9 +157,9 @@ describe('Configuration object', function()
env.set('APICAST_SERVICES_LIST', '42,21')

ngx.log = capture_log
local filtered_services = filter_services(mockservices, {"21"})
local services_returned = filter_services(mockservices, {"21"})

assert.same(filtered_services, {mockservices[1], mockservices[3]})
assert.same(services_returned, {mockservices[1], mockservices[3]})

-- Inspect the captured logs
assert.is_not_nil(captured_logs)
Expand Down

0 comments on commit 1e2b984

Please sign in to comment.