Skip to content

Commit 8a490e9

Browse files
committed
Drop log verbosity levels
In the scope of unified logging, new options -vv and -vvv were introduced. They set the luatest log level to VERBOSE and DEBUG, respectively. Actually, there's no need to suppress any logging because it goes to a file and doesn't spam the output. Besides, it's ugly that we mix luatest logging with luatest output verbosity. Let's drop the levels and use log.info instead of log.verbose or log.debug everywhere in luatest. No changelog because the feature was added by commit f8a1c10 ("Add logging to unified file"), which hasn't been released yet.
1 parent 136ade3 commit 8a490e9

File tree

6 files changed

+14
-33
lines changed

6 files changed

+14
-33
lines changed

luatest/helpers.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function helpers.retrying(config, fn, ...)
6969
if (clock.time() - started_at) > timeout then
7070
return fn(...)
7171
end
72-
log.verbose('Retrying in %d sec due to error: %s', delay, result)
72+
log.info('Retrying in %d sec due to error: %s', delay, result)
7373
fiber.sleep(delay)
7474
end
7575
end

luatest/hooks.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ local function run_group_hooks(runner, group, hooks_type)
241241
end
242242

243243
local function run_test_hooks(self, test, hooks_type, legacy_name)
244-
log.verbose('Run hook %s', hooks_type)
244+
log.info('Run hook %s', hooks_type)
245245
local group = test.group
246246
local hook
247247
-- Support for group.setup/teardown methods (legacy API)
@@ -256,7 +256,7 @@ local function run_test_hooks(self, test, hooks_type, legacy_name)
256256
end
257257

258258
local function run_named_test_hooks(self, test, hooks_type)
259-
log.verbose('Run hook %s', hooks_type)
259+
log.info('Run hook %s', hooks_type)
260260
local group = test.group
261261
local hook = group['run_' .. hooks_type]
262262
if hook then

luatest/log.lua

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,6 @@ function log.info(msg, ...)
3030
return _log('info', msg, ...)
3131
end
3232

33-
function log.verbose(msg, ...)
34-
return _log('verbose', msg, ...)
35-
end
36-
37-
function log.debug(msg, ...)
38-
return _log('debug', msg, ...)
39-
end
40-
4133
function log.warn(msg, ...)
4234
return _log('warn', msg, ...)
4335
end

luatest/process.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ function Process.mt:initialize()
7777
self._pid_ull = ffi.cast('void*', 0ULL + self.pid)
7878
ffi.gc(self._pid_ull, function(x)
7979
local pid = tonumber(ffi.cast(ffi.typeof(0ULL), x))
80-
log.debug("Killing GC'ed process %d", pid)
80+
log.info("Killing GC'ed process %d", pid)
8181
Process.kill_pid(pid, nil, {quiet = true})
8282
end)
8383
end

luatest/runner.lua

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,7 @@ function Runner.run(args, options)
9696
-- Initialize logging for luatest runner.
9797
-- The log format will be as follows:
9898
-- YYYY-MM-DD HH:MM:SS.ZZZ [ID] main/.../luatest I> ...
99-
require('log').cfg{
100-
log = log_cfg,
101-
level = options.log_level or 5,
102-
}
99+
require('log').cfg{log = log_cfg}
103100
end
104101

105102
if options.help then
@@ -132,8 +129,6 @@ Options:
132129
-h, --help: Print this help
133130
--version: Print version information
134131
-v, --verbose: Increase output verbosity for luatest runnner
135-
-vv, Increase log verbosity to VERBOSE level for luatest runnner
136-
-vvv, Increase log verbosity to DEBUG level for luatest runnner
137132
-q, --quiet: Set verbosity to minimum
138133
-c, --no-capture Disable capture
139134
-b Print full backtrace (don't remove luatest frames)
@@ -189,12 +184,6 @@ function Runner.parse_cmd_line(args)
189184
result.version = true
190185
elseif arg == '--verbose' or arg == '-v' then
191186
result.verbosity = GenericOutput.VERBOSITY.VERBOSE
192-
elseif arg == '-vv' then
193-
result.verbosity = GenericOutput.VERBOSITY.VERBOSE
194-
result.log_level = 6 -- verbose
195-
elseif arg == '-vvv' then
196-
result.verbosity = GenericOutput.VERBOSITY.VERBOSE
197-
result.log_level = 7 -- debug
198187
elseif arg == '--quiet' or arg == '-q' then
199188
result.verbosity = GenericOutput.VERBOSITY.QUIET
200189
elseif arg == '--fail-fast' or arg == '-f' then
@@ -350,13 +339,13 @@ function Runner.mt:bootstrap()
350339
load_tests(path)
351340
end
352341
self.groups = self.luatest.groups
353-
log.verbose('Bootstrap finished: %d test(s), %d group(s)', #self.paths, #self.groups)
342+
log.info('Bootstrap finished: %d test(s), %d group(s)', #self.paths, #self.groups)
354343
end
355344

356345
function Runner.mt:cleanup()
357346
if not self.no_clean then
358347
fio.rmtree(Server.vardir)
359-
log.verbose('Directory %s removed via cleanup procedure', Server.vardir)
348+
log.info('Directory %s removed via cleanup procedure', Server.vardir)
360349
end
361350
end
362351

@@ -540,7 +529,7 @@ function Runner.mt:run_tests(tests_list)
540529
end
541530
rawget(_G, 'current_test').value = test
542531
self:run_test(test)
543-
log.verbose('Test %s marked as %s', test.name, test.status)
532+
log.info('Test %s marked as %s', test.name, test.status)
544533
if self.result.aborted then
545534
break
546535
end

luatest/server.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ function Server:new(object, extra)
127127
if not object.tests[t.name] then
128128
object.tests[t.name] = t
129129
t.servers[object.id] = object
130-
log.verbose('Server %s used in %s test', object.alias, t.name)
130+
log.info('Server %s used in %s test', object.alias, t.name)
131131
end
132132
end
133133
return v(...)
@@ -513,7 +513,7 @@ end
513513
-- following string: `Failed to copy artifacts for server (alias: <alias>, workdir: <workdir>)`.
514514
function Server:save_artifacts()
515515
if self.artifacts_saved then
516-
log.verbose('Artifacts of server %s already saved to %s', self.alias, self.artifacts)
516+
log.info('Artifacts of server %s already saved to %s', self.alias, self.artifacts)
517517
return
518518
end
519519
local ok, err = fio.copytree(self.workdir, self.artifacts)
@@ -522,15 +522,15 @@ function Server:save_artifacts()
522522
:format(self.alias, fio.basename(self.workdir))
523523
log.error(('%s: %s'):format(self.artifacts, err))
524524
end
525-
log.verbose('Artifacts of server %s saved from %s to %s',
525+
log.info('Artifacts of server %s saved from %s to %s',
526526
self.alias, self.workdir, self.artifacts)
527527
self.artifacts_saved = true
528528
end
529529

530530
-- Wait until the given condition is `true` (anything except `false` and `nil`).
531531
-- Throws an error when the server process is terminated or timeout exceeds.
532532
local function wait_for_condition(cond_desc, server, func, ...)
533-
log.verbose('Wait for %s condition for server %s (pid: %d) within %d sec',
533+
log.info('Wait for %s condition for server %s (pid: %d) within %d sec',
534534
cond_desc, server.alias, server.process.pid, WAIT_TIMEOUT)
535535
local deadline = clock.time() + WAIT_TIMEOUT
536536
while true do
@@ -559,7 +559,7 @@ function Server:stop()
559559
self:coverage('shutdown')
560560
end
561561
self.net_box:close()
562-
log.verbose('Connection to server %s (pid: %d) closed', self.alias, self.process.pid)
562+
log.info('Connection to server %s (pid: %d) closed', self.alias, self.process.pid)
563563
self.net_box = nil
564564
end
565565

@@ -895,7 +895,7 @@ function Server:grep_log(pattern, bytes_num, opts)
895895
return rawget(_G, 'box_cfg_log_file') or box.cfg.log end)
896896
local file = fio.open(filename, {'O_RDONLY', 'O_NONBLOCK'})
897897

898-
log.verbose('Trying to grep %s in server\'s log file %s', pattern, filename)
898+
log.info('Trying to grep %s in server\'s log file %s', pattern, filename)
899899

900900
local function fail(msg)
901901
local err = errno.strerror()

0 commit comments

Comments
 (0)