Skip to content

Commit

Permalink
Add max_log_level config option
Browse files Browse the repository at this point in the history
Replaces --enable-debug-log
  • Loading branch information
bmerry committed Aug 22, 2023
1 parent 2bad04a commit 34cc890
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 9 deletions.
11 changes: 10 additions & 1 deletion doc/migrate-4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ below shows corresponding Meson options:
autotools meson
====================================== =====================================
``--enable-debug-symbols`` ``debug=true`` or ``buildtype=...``
``--enable-debug-log`` ``debug_log=true``
``--enable-debug-log`` ``max_log_level=debug``
``--enable-coverage`` ``b_coverage=true``
``--disable-optimized`` ``optimization=0`` or ``buildtype=debug``
``--enable-lto`` ``b_lto=true``
Expand Down Expand Up @@ -74,3 +74,12 @@ instead created as part of the build. This requires Python, with the

An advantage of this approach is that it is now possible to directly build
from a git checkout without any preparatory steps.

Python configuration
--------------------
When building the Python bindings from source, it was previously only possible
to adjust the build-time configuration by editing source files. With
the new build system, it's now possible to `pass options`_ on the command
line.

.. _pass options: https://meson-python.readthedocs.io/en/latest/how-to-guides/config-settings.html
11 changes: 6 additions & 5 deletions doc/py-logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ Logging
-------
Logging is done with the standard Python :py:mod:`logging` module, and logging
can be configured with the usual utilities. However, in the default build the
debug logging is completely disabled for performance reasons [#]_. To enable
it, add :samp:`-DSPEAD2_MAX_LOG_LEVEL=spead2::log_level::debug` to the compiler
options in :file:`setup.py`.
debug logging is completely disabled for performance reasons. To enable
it, you need to set the Meson option ``max_log_level=debug``. For example, if
installing with :command:`pip`, use

.. [#] Logging is done from separate C threads, which have to wait for
Python's Global Interpreter Lock (GIL) in order to do logging.
.. code:: sh
pip install --config-settings=setup-args=-Dmax_log_level=debug
2 changes: 2 additions & 0 deletions include/spead2/common_features.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,6 @@
#define SPEAD2_USE_POSIX_SEMAPHORES @SPEAD2_USE_POSIX_SEMAPHORES@
#define SPEAD2_USE_PCAP @SPEAD2_USE_PCAP@

#define SPEAD2_MAX_LOG_LEVEL @SPEAD2_MAX_LOG_LEVEL@

#endif // SPEAD2_COMMON_FEATURES_H
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ conf.set10('SPEAD2_USE_PTHREAD_SETAFFINITY_NP', use_pthread_setaffinity_np)
conf.set10('SPEAD2_USE_FMV', use_fmv)
conf.set10('SPEAD2_USE_MOVNTDQ', use_movntdq)
conf.set10('SPEAD2_USE_PCAP', pcap_dep.found())
conf.set('SPEAD2_MAX_LOG_LEVEL', '(spead2::log_level::' + get_option('max_log_level') + ')')

gen_loader = files('gen/gen_loader.py')
gen_templates = files('gen/template.cpp', 'gen/template.h')
Expand Down
2 changes: 1 addition & 1 deletion meson.options
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ option('gdrapi', type : 'feature', description : 'Build gdrcopy examples')
option('unit_test', type : 'feature', description : 'Build the unit tests')

option('python', type : 'boolean', value : false, description : 'Build Python bindings (for mesonpy; do not use directly)')
option('debug_log', type : 'boolean', value : false, description : 'Generate debug log messages (slow)')
option('max_log_level', type : 'combo', choices : ['debug', 'info', 'warning'], value : 'info', description : 'Generate debug log messages (slow)')
option('python_split_debug', type : 'boolean', value : false, description : 'Split debug symbols into separate files (Python module only)')
2 changes: 0 additions & 2 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ ssconfig = ss.apply(conf)

# Targets

# TODO: handle debug_log user option

if not get_option('python')
st_lib = static_library(
'spead2',
Expand Down

0 comments on commit 34cc890

Please sign in to comment.