[libcamera-devel,v2,0/4] Extend the logger with categories and configuration
mbox series

Message ID 20190121195606.8526-1-laurent.pinchart@ideasonboard.com
Headers show
Series
  • Extend the logger with categories and configuration
Related show

Message

Laurent Pinchart Jan. 21, 2019, 7:56 p.m. UTC
Hello,

This patch series extends the logging infrastructure with support for
logging categories, and implements configuration of the logger from
environment variables.

Patch 1/4 adds log categories, patch 2/4 and 3/4 configure log levels
and the log output file from environment variables, and patch 4/4 makes
uses of categories through the code base.

Compared to v1, two merged patches have been dropped, and the LOG() and
LOG() macros have been merged together, with the documentation updated
accordingly.

As with v1, I'm not entirely happy with the following:

- I would like the LOG() macro to automatically log to the category
  defined with LOG_DEFINE_CATEGORY() (or declared with
  LOG_DECLARE_CATEGORY()) when used without an explicit category and
  when the compilation unit has a single category declared (or possibly
  the first or last category declared when there are several). I haven't
  found a good way to implement this, it is still an exercise for the
  reader.

- A test case for log environment variables parsing would be nice, but
  that's hard to do as the implementation is very private.

- Patch 4/4 heavily violates checkstyle.py, and after digging into the
  astyle options I unfortunately found out that the indentation for this
  specific case is hardcoded. However, the new clang-format support for
  checkstyle.py doesn't complain, so I'm enclined to leave it as-is.

- Documenting the LOG() macro properly and hiding the internal macros
  from log.h without any doxygen warning required adding a #ifndef
  __DOXYGEN__ in log.h, which I don't like much.

I don't think any of those issues are blockers, so I plan to push the
patches to the master branch soon.

Laurent Pinchart (4):
  libcamera: log: Add log categories
  libcamera: log: Get log levels from the environment
  libcamera: log: Get log output file from the environment
  libcamera: Use log categories

 Documentation/Doxyfile.in               |   2 +-
 src/libcamera/camera_manager.cpp        |  14 +-
 src/libcamera/device_enumerator.cpp     |  25 +-
 src/libcamera/event_dispatcher.cpp      |   4 +
 src/libcamera/event_dispatcher_poll.cpp |  28 +-
 src/libcamera/include/log.h             |  56 ++-
 src/libcamera/log.cpp                   | 436 ++++++++++++++++++++++--
 src/libcamera/media_device.cpp          |  52 +--
 src/libcamera/media_object.cpp          |   7 +-
 src/libcamera/pipeline_handler.cpp      |   5 +-
 src/libcamera/timer.cpp                 |   7 +-
 src/libcamera/v4l2_device.cpp           |  25 +-
 12 files changed, 561 insertions(+), 100 deletions(-)