Log4cxx and full file paths when used with CMake

I use Log4Cxx for logging, and I would like to use the% l directive to see where the log trace is located (file name and line number). The problem is that I also use CMake, which provides full path names for the compiler . This causes the log columns to no longer align, and is now difficult to read because log4cxx uses the __FILE__ preprocessor macro to determine this information.

Does anyone know of a workaround? I would like to indicate, for example, how to get only "filename.cpp" or better with a nesting parameter, for example, 2 nesting will be "module / submodule / filename.cpp". It seems that the CMake design works with the complete philosophy of the path, so I think that this could be solved either with the help of a preprocessor directive unknown to me, or somehow trick Log4CXX.

+3
source share
1 answer

It looks like you can try using "ConversionPattern" to at least specify the maximum width for the output of the log4cxx file:

http://logging.apache.org/log4cxx/apidocs/classlog4cxx_1_1_pattern_layout.html

Or search on the ConversionPattern page for an example configuration file:

http://logging.apache.org/log4cxx/index.html

. , , .

CMake , ( ). , , .

+1

Source: https://habr.com/ru/post/1791438/


All Articles