mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-18 07:00:06 -05:00
spa: add debug log context
Make a real debug context with a log function and move it to a new file. This way we don't need to redefine a macro. Make a new context for debugging to a log file. Make new functions to debug to a log file. Move the stringbuffer to string utils. Integrate file/line/func and topics into the debug log. We can remove some more things from the pipewire log_object function and also add support for topics.
This commit is contained in:
parent
3c67821c4a
commit
6207d98ff1
21 changed files with 231 additions and 164 deletions
|
|
@ -376,6 +376,33 @@ static inline char *spa_dtoa(char *str, size_t size, double val)
|
|||
return str;
|
||||
}
|
||||
|
||||
struct spa_strbuf {
|
||||
char *buffer;
|
||||
size_t maxsize;
|
||||
size_t pos;
|
||||
};
|
||||
|
||||
static inline void spa_strbuf_init(struct spa_strbuf *buf, char *buffer, size_t maxsize)
|
||||
{
|
||||
buf->buffer = buffer;
|
||||
buf->maxsize = maxsize;
|
||||
buf->pos = 0;
|
||||
}
|
||||
|
||||
SPA_PRINTF_FUNC(2, 3)
|
||||
static inline int spa_strbuf_append(struct spa_strbuf *buf, const char *fmt, ...)
|
||||
{
|
||||
size_t remain = buf->maxsize - buf->pos;
|
||||
ssize_t written;
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
written = vsnprintf(&buf->buffer[buf->pos], remain, fmt, args);
|
||||
va_end(args);
|
||||
if (written > 0)
|
||||
buf->pos += SPA_MIN(remain, (size_t)written);
|
||||
return written;
|
||||
}
|
||||
|
||||
/**
|
||||
* \}
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue