How to enable multiline logs instead of single-line progress-logs
Asked Answered
S

4

8

Here is a sample output of my cmake:

2017/10/27 07:51:46 Platform overridden to 'RHEL5_64'
-- cmake version: 3.2.3
-- Configuring done
-- Generating done
-- Build files have been written to: /local/home/etc
[3/3] Linking CXX shared library libsample_z.so

The last line actually shows progress (as indicated by [3/3]) and thus overwritten in-place; so I cannot see all the logs (i.e the messages correspond to [1/3] and [2/3]). I want cmake to print all logs to stay on its own line, like:

Linking CXX shared library libsample_x.so
Linking CXX shared library libsample_y.so
Linking CXX shared library libsample_z.so

What can be done in cmake to log like this?

Selfservice answered 27/10, 2017 at 8:17 Comment(2)
Do you use ninja? I had the same problem with ninja.Theone
I think yes, because I see "ninja: no work to do" when no build is required.Selfservice
T
4

The "problem" with ninja is, that it automatically detects if you are running from a shell where it can replace the progress output in line. And there are - as of October 2017 - no command line switches or environment variables to change this behavior.

Since it checks for the console's output buffer, I found that piping the output on my Windows console somewhere else does show multi-line outputs again. So i used the following pipe command:

cmake -G "Ninja" ..
cmake --build . > CON

NOTE: That will only work if you don't have this call inside a script that needs the stdout output itself again for piping it e.g. into a log file. Meaning the output is no longer on stdout after this pipe command.

Theone answered 27/10, 2017 at 8:50 Comment(1)
If you DO want to see output on stdout (seems obvious), use cmake --build . | tee /dev/null where dev/null can be name of file that will contain output as well. This usually disables color output (from compiler warnings etc.)Snuffer
A
3

Similar to the accept answer, another option is to tick ninja into not seeing the terminal by piping to cat.

ninja | cat -

This will get you multi line output, but you will loose any console coloring as well.

Abscond answered 7/8, 2021 at 13:15 Comment(0)
B
0

From man ninja:

-v     show all command lines while building
Bevon answered 5/7, 2019 at 7:26 Comment(1)
no, this will show content of all commands but not commentsRecipient
S
0

Sorry for necro posting. But as of 2024 also, it is not fixed. So for anyone in the future who absolutely can't work without fixing it, here's the solution.

Change the source code.

  1. Pull the source from github.
  2. Go to "src/line_printer.cc" file.
  3. Go to line 74.
  4. Change printf("\r"); to printf("\n");
  5. Build the program according to official documentation.
Selfrealization answered 30/6, 2024 at 7:8 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.