Skip to content

Commit

Permalink
better naming in sc_common
Browse files Browse the repository at this point in the history
  • Loading branch information
tanguyvda committed Sep 23, 2021
1 parent a054a78 commit a6ac57e
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions modules/centreon-stream-connectors-lib/sc_common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ end

local ScCommon = {}

function sc_common.new(logger)
function sc_common.new(sc_logger)
local self = {}

self.logger = logger
if not self.logger then
self.logger = sc_logger.new()
self.sc_logger = sc_logger
if not self.sc_logger then
self.sc_logger = sc_logger.new()
end

setmetatable(self, { __index = ScCommon })
Expand Down Expand Up @@ -101,7 +101,7 @@ end
function ScCommon:split (text, separator)
-- return false if text is nil or empty
if text == nil or text == "" then
self.logger:error("[sc_common:split]: could not split text because it is nil or empty")
self.sc_logger:error("[sc_common:split]: could not split text because it is nil or empty")
return false
end

Expand Down Expand Up @@ -167,7 +167,7 @@ end
function ScCommon:generate_postfield_param_string(params)
-- return false because params type is wrong
if (type(params) ~= "table") then
self.logger:error("[sc_common:generate_postfield_param_string]: parameters to convert aren't in a table")
self.sc_logger:error("[sc_common:generate_postfield_param_string]: parameters to convert aren't in a table")
return false
end

Expand Down Expand Up @@ -205,12 +205,12 @@ function ScCommon:load_json_file(json_file)
io.close(file)

-- parse it
local content = broker.json_decode(file_content)
local content, error = broker.json_decode(file_content)

-- return false if json couldn't be parsed
if (type(content) ~= "table") then
self.sc_logger:error("[sc_common:load_json_file]: file "
.. tostring(json_file) .. ". Is not a valid json file.")
if error then
self.sc_logger:error("[sc_common:load_json_file]: could not parse json file "
.. tostring(json_file) .. ". Error is: " .. tostring(error))
return false
end

Expand Down

0 comments on commit a6ac57e

Please sign in to comment.