Skip to content

Commit 81d7866

Browse files
committed
Print luatest logs to stdout when unified log is disabled
If unified logging is enabled, logs written by the runner are written both to its own log file and to the unified log file. This is consistent with how logs written by test processes are handled. However, if unified logging is disabled, then runner logs are written only to its log file while test process logs are also written to stdout and captured if capturing is enabled. Let's write runner logs to stdout in this case as well because they can be useful for debugging. No changelog because the feature was added by commit f8a1c10 ("Add logging to unified file"), which hasn't been released yet.
1 parent a27217f commit 81d7866

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

luatest/runner.lua

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,17 @@ function Runner.run(args, options)
7272
local fh = fio.open(options.log_file, {'O_CREAT', 'O_WRONLY', 'O_TRUNC'},
7373
tonumber('640', 8))
7474
rawset(_G, 'log_file', {fh = fh})
75+
end
7576

76-
local output_beautifier = OutputBeautifier:new({prefix = log_prefix})
77-
output_beautifier:enable()
77+
local output_beautifier = OutputBeautifier:new({prefix = log_prefix})
78+
output_beautifier:enable()
79+
80+
-- `tee` copy logs to file and also to standard output, but we need
81+
-- process all captured data through the OutputBeatifier object.
82+
-- So we redirect stdout to the pipe created by OutputBeautifier.
83+
log_cfg = string.format("| tee %s > /dev/fd/%d",
84+
log_cfg, output_beautifier.pipes.stdout[1])
7885

79-
-- `tee` copy logs to file and also to standard output, but we need
80-
-- process all captured data through the OutputBeatifier object.
81-
-- So we redirect stdout to the pipe created by OutputBeautifier.
82-
log_cfg = string.format("| tee %s > /dev/fd/%d",
83-
log_cfg, output_beautifier.pipes.stdout[1])
84-
end
8586
-- Logging cannot be initialized without configuring the `box` engine
8687
-- on a version less than 2.5.1 (see more details at [1]). Otherwise,
8788
-- this causes the `attempt to call field 'cfg' (a nil value)` error,

0 commit comments

Comments
 (0)