msm: camera: utils: Add support for multiline printing to log buffers

Introduce new macros to print into log buffers that prefix the
appropriate tags. This allows the usual search filters to pick up all
the lines of the log.

CRs-Fixed: 2928828
Change-Id: I3d27490b324e884eb9cce2bfd184e82418099484
Signed-off-by: Anand Ravi <ananravi@codeaurora.org>
This commit is contained in:
Anand Ravi
2021-04-17 13:21:43 -07:00
parent f77f1673d3
commit 27ad84d827
6 changed files with 146 additions and 134 deletions

View File

@@ -331,6 +331,40 @@ const char *cam_get_module_name(unsigned int module_id);
fmt, ##args); \
})
/**
* cam_print_to_buffer
* @brief: Function to print to camera logs to a buffer. Don't use directly. Use macros
* provided below.
*
* @buf: Buffer to print into
* @buf_size: Total size of the buffer
* @len: Pointer to variable used to keep track of the length
* @tag: Log level tag to be prefixed
* @module_id: Module id tag to be prefixed
* @fmt: Formatted string which needs to be print in log
* @args: Arguments which needs to be print in log
*/
void cam_print_to_buffer(char *buf, const size_t buf_size, size_t *len, unsigned int tag,
unsigned int module_id, const char *fmt, ...);
/**
* CAM_[ERR/WARN/INFO]_BUF
* @brief: Macro to print a new line into log buffer.
*
* @module_id: Module id tag to be prefixed
* @buf: Buffer to print into
* @buf_size: Total size of the buffer
* @len: Pointer to the variable used to keep track of the length
* @fmt: Formatted string which needs to be print in log
* @args: Arguments which needs to be print in log
*/
#define CAM_ERR_BUF(module_id, buf, buf_size, len, fmt, args...) \
cam_print_to_buffer(buf, buf_size, len, CAM_TYPE_ERR, module_id, fmt, ##args)
#define CAM_WARN_BUF(module_id, buf, buf_size, len, fmt, args...) \
cam_print_to_buffer(buf, buf_size, len, CAM_TYPE_WARN, module_id, fmt, ##args)
#define CAM_INFO_BUF(module_id, buf, buf_size, len, fmt, args...) \
cam_print_to_buffer(buf, buf_size, len, CAM_TYPE_INFO, module_id, fmt, ##args)
/**
* @brief : API to get camera debug settings
* @return const struct camera_debug_settings pointer.