|
VART-X
0.4.0
|
The logger module provides the logging support for VART modules. Supports logging to console, file, syslog. More...
#include <vart_logger.hpp>
Public Member Functions | |
| std::shared_ptr< struct log_context > | mod_register (const char *modname, bool need_id) |
| mod_register() - Registers a module with logger object More... | |
| void | vart_logger_log_obj (LogLevel, std::shared_ptr< struct log_context > ctx, const char *filename, const char *func, uint32_t line, const char *fmt,...) |
| vart_logger_log_obj() - Logs a module's message along with metadata like filename, function name, line number, process id, thread id. More... | |
| void | set_backend (const LogBackend *backend) |
| set_backend() - Install or remove a process-wide external log backend. More... | |
Static Public Member Functions | |
| static Logger & | get_instance () |
| get_instance() - Creates a logger() instance if not created earlier, else return an existing instance. More... | |
The logger module provides the logging support for VART modules. Supports logging to console, file, syslog.
|
inlinestatic |
get_instance() - Creates a logger() instance if not created earlier, else return an existing instance.
On first construction Logger reads the environment variable whose name is given by the VART_CORE_DEBUG macro (the readable env-var name is "VART_CORE_DEBUG_ENV") to populate per-module and global log levels. Malformed values do not throw; the error is printed to std::cerr and defaults are kept. Default module instance id is stored as -1 and is updated when each module instance registers. Logger also reads the environment variable named by the VART_LOG_FILE_PATH macro:
| std::shared_ptr<struct log_context> vart::Logger::mod_register | ( | const char * | modname, |
| bool | need_id | ||
| ) |
mod_register() - Registers a module with logger object
| [in] | modname | Module name to register with logger |
| [in] | need_id | Flag describing the need for an id to be appended to module name during logging |
If the module is already registered with the logger, its instance id is incremented, else a default instance id = 0 is assigned. Module instance log level is assigned from logger object's database or from global log level if per module log level is not provided by user. If need_id is set to false, module instance id is not appended to module's instance name. Components such as 'videoframe', 'memory' need to set this flag to false as there can be too many instances of those components in a single pipeline use case and can be be distinguished by their pointers. Components representing IP blocks can set this to true to distinguish IP instances.
| void vart::Logger::set_backend | ( | const LogBackend * | backend | ) |
set_backend() - Install or remove a process-wide external log backend.
Filter order: built-in env/module level -> accept (optional) -> format -> deliver when installed, otherwise the default destination.
Passing nullptr clears the current backend and restores the default destination. A non-null backend replaces the current backend. When backend is non-null, backend->deliver must be non-null. Do not call back into VART_LOG_* from accept or deliver callbacks.
| void vart::Logger::vart_logger_log_obj | ( | LogLevel | , |
| std::shared_ptr< struct log_context > | ctx, | ||
| const char * | filename, | ||
| const char * | func, | ||
| uint32_t | line, | ||
| const char * | fmt, | ||
| ... | |||
| ) |
vart_logger_log_obj() - Logs a module's message along with metadata like filename, function name, line number, process id, thread id.
| [in] | LogLevel | Logging level with which module logs a message |
| [in] | ctx | Module's logger context obtained with mod_register() |
| [in] | filename | Source code filename from which this logging is triggered |
| [in] | func | Source code function name |
| [in] | line | Source code line number |
| [in] | fmt | Format string passed for logging, followed by a printf-style variadic argument list. |