summaryrefslogtreecommitdiff
path: root/src/libcamera/log.cpp
AgeCommit message (Collapse)Author
2019-07-17libcamera: logging: add syslog, stream, and nowhere logging targetsPaul Elder
Allow logging to syslog, or any given ostream, or to nowhere. The logging API is updated to accomodate these new logging destinations. LogMessage is modified to allow this. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-07-12libcamera: logging: add logging API for applicationsPaul Elder
Currently the log file and the log level can only be set via environment variables, but applications may also want to set the log file and the log level at run time. Provide an API for this. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-04-26libcamera: log: Add a LogInvalid entry to LogSeverityLaurent Pinchart
enum LogSeverity values are assigned or compared to -1 to flag invalid log severities. This generates compilation warnings with clang. Fix it by adding an explicit LogInvalid entry to the enumeration. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-04-19libcamera: Include header related to source file firstLaurent Pinchart
Include the header file corresponding to the source file in the very first position. This complies with the Google C++ coding style guideliens, and helps ensuring that the headers are self-contained. Three bugs are already caught by this change (missing includes or forward declarations) in device_enumerator.h, event_dispatcher_poll.h and pipeline_handler.h. Fix them. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-18libcamera: log: Mark Loggable::_log() methods as constLaurent Pinchart
The methods don't modify the object instance, mark them as const. This allows using the LOG() macro from a const method of a Loggable object. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-03libcamera: utils: Use internal secure_getenv() implementationKieran Bingham
The secure_getenv() call is not provided by all C libraries. Support this feature by implementing our own version. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-04-03libcamera: utils: Use internal basename implementation.Kieran Bingham
Differing implementations of basename() exist, some of which may modify the content of the string passed as an argument. The implementation of basename() is trivial, thus to support different C librariese, provide our own version which accepts and returns a const char *. Update the call sites to use the new implementation. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-02-11libcamera: log: Allow extending log messagesLaurent Pinchart
Introduce a base Loggable class that can be inherited from by other classes to support adding per-instance information to the log messages. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-01-23libcamera: log: Fix two typosKieran Bingham
Two incorrect spellings are fixed. 'logr' -> 'log' 'environement' -> 'environment' Fixes: 747ace042cc1 ("libcamera: log: Get log levels from the environment") Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> The log levels configuration is stored in category:level pairs, not category=value. Fix the documentation. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-01-21libcamera: log: Get log output file from the environmentLaurent Pinchart
If the LIBCAMERA_LOG_FILE environment variable is set, open the file it points to and redirect the logger output to it. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-01-21libcamera: log: Get log levels from the environmentLaurent Pinchart
Set the log level for each log category from the environment variable LIBCAMERA_LOG_LEVELS. The variable contains a comma-separated list of category:level pairs, and category names can include wildcards. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-01-21libcamera: log: Add log categoriesLaurent Pinchart
Log categories are used to group log messages by topic. Introduce support for categories by making the LOG() macro variadic. Support for configuring log level per category will be introduced in a subsequent commit. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-01-17libcamera: log: Fix coding style warningsKieran Bingham
The checkstyle utility highlights some minor warnings against the logger implementation. Fix these up. Fixes: edbd2059d8a4 ("libcamera: Add initial logger") Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-01-14libcamera: log: Fix unknown log level representationKieran Bingham
Commit 99a3e7bcfb38 ("libcamera: log: Add a LogFatal log level") expanded the text representation of the log levels to support the FATAL string, but left the default unknown match at four characters. This code should never expect to be executed, but for completeness match the string lengths by adding an extra character to the result. Fixes: 99a3e7bcfb38 ("libcamera: log: Add a LogFatal log level") Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-01-10libcamera: Document missing parameters and return valuesLaurent Pinchart
Several functions are missing documentation for some of them parameters and/or for their return value. Fix this. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-01-08libcamera: log: Pad timestamp fields with zerosLaurent Pinchart
The logger prints the timestamp fields with a fixed width, but pads them with spaces instead of zeros. Fix this. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-01-08libcamera: log: Add an ASSERT macroLaurent Pinchart
The ASSERT() macro is similar to the assert() macro defined by the C standard, but uses the libcamera logging infrastructure. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-01-08libcamera: log: Add a LogFatal log levelLaurent Pinchart
The LogFatal log level is similar to the LogError level, but additionally abort program execution. This is useful to implement assertion handlers. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2018-12-19libcamera: log: Add a debug log levelLaurent Pinchart
Many of the message logged by the library will be debug messages, we thus need a debug log level. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2018-12-12libcamera: log: Document the LogMessage classLaurent Pinchart
Fix Doxygen build warnings by adding the missing documentation for the LogMessage class. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2018-12-12libcamera: log: Fix Doxygen documentationLaurent Pinchart
Now that the documentation can be compiled, Doxygen throws a few warnings due to incorrect enum field naming. Fix it. The \file block needs to be named after the header file in order for Doxygen to document any global function, variable, typedef or enum defined in the header (as documented in the Doxygen manual under the \file command). We thus need to use log.h as the file name. No \file block is needed for the .cpp file, as we don't want to generate documentation for internal private globals. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2018-12-11libcamera: log: Fix miscellaneous coding style issuesLaurent Pinchart
Those issues were pointed out during review. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2018-12-06libcamera: Add initial loggerLaurent Pinchart
The logger is based on the ostream API, allowing code to log messages in a native way. It automatically logs the time stamp, severity level, file name and line number. Many important features are missing, such as logging to file, logging classes, and log filtering based on the severity level, file name and class. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>