Skip to content

Commit

Permalink
Quote some logged strings
Browse files Browse the repository at this point in the history
Now, that auto-quoting is disabled in the log, let's quote server names
and conditions because without quoting they look ugly.

No changelog as this is a minor change related to the previous commit.
  • Loading branch information
locker committed Oct 29, 2024
1 parent 59cb003 commit 32fe345
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions luatest/replica_set.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function ReplicaSet:initialize()
else
self.servers = {}
end
log.info('Replica set %s initialized', self.id)
log.info('Replica set %q initialized', self.id)
end

--- Build a server object for the replica set.
Expand Down Expand Up @@ -148,7 +148,7 @@ function ReplicaSet:delete_server(alias)
if server_index then
table.remove(self.servers, server_index)
else
log.warn('Server %s does not exist in replica set %s', alias, self.id)
log.warn('Server %q does not exist in replica set %q', alias, self.id)
end
end

Expand All @@ -174,7 +174,7 @@ function ReplicaSet:start(opts)
server:wait_until_ready()
end
end
log.info('All servers started in replica set %s', self.id)
log.info('All servers started in replica set %q', self.id)
end

--- Stop all servers in the replica set.
Expand Down Expand Up @@ -236,7 +236,7 @@ function ReplicaSet:wait_for_fullmesh(opts)
end
end
end, self)
log.info('Full mesh is ready in replica set %s', self.id)
log.info('Full mesh is ready in replica set %q', self.id)
end

return ReplicaSet
20 changes: 10 additions & 10 deletions luatest/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function Server:new(object, extra)
if not object.tests[t.name] then
object.tests[t.name] = t
t.servers[object.id] = object
log.info('Server %s used in %s test', object.alias, t.name)
log.info('Server %q used in %s test', object.alias, t.name)
end
end
return v(...)
Expand Down Expand Up @@ -461,7 +461,7 @@ function Server:start(opts)
self:wait_until_ready()
end

log.info('Server %s (pid: %d) started', self.alias, self.process.pid)
log.info('Server %q (pid: %d) started', self.alias, self.process.pid)
end

--- Restart the server with the given parameters.
Expand Down Expand Up @@ -495,7 +495,7 @@ function Server:restart(params, opts)
}, {wait_until_ready = '?boolean'})

if not self.process then
log.warn('Cannot restart server %s since its process not started', self.alias)
log.warn('Cannot restart server %q since its process not started', self.alias)
end
self:stop()

Expand All @@ -504,7 +504,7 @@ function Server:restart(params, opts)
end

self:start(opts)
log.info('Server %s (pid: %d) restarted', self.alias, self.process.pid)
log.info('Server %q (pid: %d) restarted', self.alias, self.process.pid)
end

-- Save server artifacts by copying the working directory.
Expand All @@ -513,7 +513,7 @@ end
-- following string: `Failed to copy artifacts for server (alias: <alias>, workdir: <workdir>)`.
function Server:save_artifacts()
if self.artifacts_saved then
log.info('Artifacts of server %s already saved to %s', self.alias, self.artifacts)
log.info('Artifacts of server %q already saved to %s', self.alias, self.artifacts)
return
end
local ok, err = fio.copytree(self.workdir, self.artifacts)
Expand All @@ -522,15 +522,15 @@ function Server:save_artifacts()
:format(self.alias, fio.basename(self.workdir))
log.error(('%s: %s'):format(self.artifacts, err))
end
log.info('Artifacts of server %s saved from %s to %s',
log.info('Artifacts of server %q saved from %s to %s',
self.alias, self.workdir, self.artifacts)
self.artifacts_saved = true
end

-- Wait until the given condition is `true` (anything except `false` and `nil`).
-- Throws an error when the server process is terminated or timeout exceeds.
local function wait_for_condition(cond_desc, server, func, ...)
log.info('Wait for %s condition for server %s (pid: %d) within %d sec',
log.info('Wait for %q condition for server %q (pid: %d) within %d sec',
cond_desc, server.alias, server.process.pid, WAIT_TIMEOUT)
local deadline = clock.time() + WAIT_TIMEOUT
while true do
Expand Down Expand Up @@ -559,7 +559,7 @@ function Server:stop()
self:coverage('shutdown')
end
self.net_box:close()
log.info('Connection to server %s (pid: %d) closed', self.alias, self.process.pid)
log.info('Connection to server %q (pid: %d) closed', self.alias, self.process.pid)
self.net_box = nil
end

Expand All @@ -582,7 +582,7 @@ function Server:stop()
error(('Memory leak during process execution (alias: %s, workdir: %s, pid: %s)\n%s')
:format(self.alias, workdir, pid, stderr))
end
log.info('Process of server %s (pid: %d) killed', self.alias, self.process.pid)
log.info('Process of server %q (pid: %d) killed', self.alias, self.process.pid)
self.process = nil
end
end
Expand Down Expand Up @@ -895,7 +895,7 @@ function Server:grep_log(pattern, bytes_num, opts)
return rawget(_G, 'box_cfg_log_file') or box.cfg.log end)
local file = fio.open(filename, {'O_RDONLY', 'O_NONBLOCK'})

log.info('Trying to grep %s in server\'s log file %s', pattern, filename)
log.info('Trying to grep %q in server\'s log file %s', pattern, filename)

local function fail(msg)
local err = errno.strerror()
Expand Down

0 comments on commit 32fe345

Please sign in to comment.