From: softworkz <ffmpegagent@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Cc: softworkz <softworkz@hotmail.com>
Subject: [FFmpeg-devel] [PATCH v3 1/4] avutil/log: Add callback for context prefix formatting
Date: Thu, 06 Mar 2025 20:59:08 +0000
Message-ID: <b8702de13b42e42940a3186060fed0a7a53455f9.1741294751.git.ffmpegagent@gmail.com> (raw)
In-Reply-To: <pull.59.v3.ffstaging.FFmpeg.1741294751.ffmpegagent@gmail.com>
From: softworkz <softworkz@hotmail.com>
also adds a log flag AV_LOG_PRINT_MEMADDRESSES, which is meant to
control prefix formatting. The actual formatting has to be performed
by the consuming application which needs to provide a formatting
callback via av_log_set_formatprefix_callback.
Signed-off-by: softworkz <softworkz@hotmail.com>
---
doc/APIchanges | 4 ++++
libavutil/log.c | 24 ++++++++++++++++++------
libavutil/log.h | 29 +++++++++++++++++++++++++++++
libavutil/version.h | 2 +-
4 files changed, 52 insertions(+), 7 deletions(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index 5a64836e25..92e4a2e055 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -1,5 +1,9 @@
The last version increases of all libraries were on 2024-03-07
+2025-03-xx - xxxxxxxxxx - lavu 59.59.100 - log.h
+ Add flag AV_LOG_PRINT_MEMADDRESSES, av_log_set_formatprefix_callback,
+ av_log_formatprefix_default_callback
+
API changes, most recent first:
2025-03-01 - xxxxxxxxxx - lavu 59.58.100 - pixfmt.h
diff --git a/libavutil/log.c b/libavutil/log.c
index c5ee876a88..6697bdba70 100644
--- a/libavutil/log.c
+++ b/libavutil/log.c
@@ -315,6 +315,14 @@ static void format_date_now(AVBPrint* bp_time, int include_date)
}
}
+void av_log_formatprefix_default_callback(AVBPrint* buffer, AVClass** avcl, int log_flags)
+{
+ av_bprintf(buffer+0, "[%s @ %p] ", item_name(avcl, *avcl), avcl);
+}
+
+static void (*av_log_formatprefix_callback)(AVBPrint* part, AVClass** avcl, int log_flags) =
+ av_log_formatprefix_default_callback;
+
static void format_line(void *avcl, int level, const char *fmt, va_list vl,
AVBPrint part[5], int *print_prefix, int type[2])
{
@@ -327,17 +335,16 @@ static void format_line(void *avcl, int level, const char *fmt, va_list vl,
if(type) type[0] = type[1] = AV_CLASS_CATEGORY_NA + 16;
if (*print_prefix && avc) {
+
if (avc->parent_log_context_offset) {
- AVClass** parent = *(AVClass ***) (((uint8_t *) avcl) +
- avc->parent_log_context_offset);
+ AVClass** parent = *(AVClass ***) ((uint8_t *)avcl + avc->parent_log_context_offset);
if (parent && *parent) {
- av_bprintf(part+0, "[%s @ %p] ",
- item_name(parent, *parent), parent);
+ av_log_formatprefix_callback(part, parent, flags);
if(type) type[0] = get_category(parent);
}
}
- av_bprintf(part+1, "[%s @ %p] ",
- item_name(avcl, avc), avcl);
+ av_log_formatprefix_callback(part, avcl, flags);
+
if(type) type[1] = get_category(avcl);
}
@@ -485,6 +492,11 @@ int av_log_get_flags(void)
return flags;
}
+void av_log_set_formatprefix_callback(void (*callback)(AVBPrint* buffer, AVClass** avcl, int log_flags))
+{
+ av_log_formatprefix_callback = callback;
+}
+
void av_log_set_callback(void (*callback)(void*, int, const char*, va_list))
{
av_log_callback = callback;
diff --git a/libavutil/log.h b/libavutil/log.h
index dd094307ce..a69888c1ad 100644
--- a/libavutil/log.h
+++ b/libavutil/log.h
@@ -24,6 +24,7 @@
#include <stdarg.h>
#include "attributes.h"
#include "version.h"
+#include "bprint.h"
typedef enum {
AV_CLASS_CATEGORY_NA = 0,
@@ -323,6 +324,29 @@ int av_log_get_level(void);
*/
void av_log_set_level(int level);
+/**
+ * Set the prefix formatting callback
+ *
+ * @note The callback must be thread safe, even if the application does not use
+ * threads itself as some codecs are multithreaded.
+ *
+ * @see av_log_formatprefix_default_callback
+ *
+ * @param callback A formatting function with a compatible signature.
+ */
+void av_log_set_formatprefix_callback(void (*callback)(AVBPrint* buffer, AVClass** avcl, int log_flags));
+
+/**
+ * Default prefix formatting callback
+ *
+ * It prints the message to stderr, optionally colorizing it.
+ *
+ * @param buffer A pointer to the print buffer.
+ * @param avcl The AVClass reference for which to format the prefix.
+ * @param log_flags The enabled logging flags
+ */
+void av_log_formatprefix_default_callback(AVBPrint* buffer, AVClass** avcl, int log_flags);
+
/**
* Set the logging callback
*
@@ -416,6 +440,11 @@ int av_log_format_line2(void *ptr, int level, const char *fmt, va_list vl,
*/
#define AV_LOG_PRINT_DATETIME 8
+/**
+ * Print memory addresses instead of logical ids in the AVClass prefix.
+ */
+#define AV_LOG_PRINT_MEMADDRESSES 16
+
void av_log_set_flags(int arg);
int av_log_get_flags(void);
diff --git a/libavutil/version.h b/libavutil/version.h
index 4b584fd569..b6467e2a6d 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 59
-#define LIBAVUTIL_VERSION_MINOR 58
+#define LIBAVUTIL_VERSION_MINOR 59
#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
--
ffmpeg-codebot
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2025-03-06 20:59 UTC|newest]
Thread overview: 98+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-05 15:38 [FFmpeg-devel] [PATCH] avutil/log: Replace addresses in log output with simple ids softworkz
2025-03-05 15:40 ` Nicolas George
2025-03-05 15:45 ` Soft Works
2025-03-05 15:48 ` Soft Works
2025-03-06 10:08 ` Nicolas George
2025-03-06 17:02 ` Soft Works
2025-03-06 17:38 ` Marvin Scholz
2025-03-06 17:44 ` Soft Works
2025-03-06 17:49 ` Marvin Scholz
2025-03-06 18:16 ` Soft Works
2025-03-06 18:58 ` Marvin Scholz
2025-03-06 19:27 ` Soft Works
2025-03-06 20:01 ` Marvin Scholz
2025-03-06 20:48 ` Soft Works
2025-03-06 20:56 ` Soft Works
2025-03-05 15:42 ` Soft Works
2025-03-05 16:23 ` Gyan Doshi
2025-03-05 16:30 ` Soft Works
2025-03-05 17:14 ` Gyan Doshi
2025-03-05 18:19 ` [FFmpeg-devel] [PATCH v2 0/3] " ffmpegagent
2025-03-05 18:19 ` [FFmpeg-devel] [PATCH v2 1/3] " softworkz
2025-03-05 18:19 ` [FFmpeg-devel] [PATCH v2 2/3] fftools/opt_common: add memaddresses log flag softworkz
2025-03-05 18:19 ` [FFmpeg-devel] [PATCH v2 3/3] doc/fftools-common-opts: document " softworkz
2025-03-06 10:04 ` [FFmpeg-devel] [PATCH v2 0/3] avutil/log: Replace addresses in log output with simple ids Nicolas George
2025-03-06 16:38 ` Soft Works
2025-03-06 16:43 ` Nicolas George
2025-03-06 17:05 ` Soft Works
2025-03-06 17:38 ` Soft Works
2025-03-06 20:59 ` [FFmpeg-devel] [PATCH v3 0/4] " ffmpegagent
2025-03-06 20:59 ` softworkz [this message]
2025-03-07 9:44 ` [FFmpeg-devel] [PATCH v3 1/4] avutil/log: Add callback for context prefix formatting Nicolas George
2025-03-07 17:23 ` Soft Works
2025-03-07 17:30 ` Hendrik Leppkes
2025-03-07 18:02 ` Soft Works
2025-03-06 20:59 ` [FFmpeg-devel] [PATCH v3 2/4] fftools/opt_common: add memaddresses log flag softworkz
2025-03-06 20:59 ` [FFmpeg-devel] [PATCH v3 3/4] fftools: Provide a log formatting callback for context prefixes softworkz
2025-03-06 20:59 ` [FFmpeg-devel] [PATCH v3 4/4] doc/fftools-common-opts: document memaddresses log flag softworkz
2025-03-08 23:02 ` [FFmpeg-devel] [PATCH v4 0/4] avutil/log: Replace addresses in log output with simple ids ffmpegagent
2025-03-08 23:02 ` [FFmpeg-devel] [PATCH v4 1/4] avutil/log: Add AV_LOG_PRINT_MEMADDRESSES logging flag softworkz
2025-03-08 23:02 ` [FFmpeg-devel] [PATCH v4 2/4] fftools/opt_common: add memaddresses log flag softworkz
2025-03-08 23:02 ` [FFmpeg-devel] [PATCH v4 3/4] fftools: Provide a an fftools-specific logging callback function softworkz
2025-03-09 17:52 ` Michael Niedermayer
2025-03-09 18:59 ` Soft Works
2025-03-08 23:02 ` [FFmpeg-devel] [PATCH v4 4/4] doc/fftools-common-opts: document memaddresses log flag softworkz
2025-03-09 19:01 ` [FFmpeg-devel] [PATCH v5 0/5] avutil/log: Replace addresses in log output with simple ids ffmpegagent
2025-03-09 19:01 ` [FFmpeg-devel] [PATCH v5 1/5] avutil/log: Add AV_LOG_PRINT_MEMADDRESSES logging flag softworkz
2025-03-09 19:05 ` Nicolas George
2025-03-09 19:11 ` Soft Works
2025-03-09 19:01 ` [FFmpeg-devel] [PATCH v5 2/5] fftools/opt_common: add memaddresses log flag softworkz
2025-03-09 19:01 ` [FFmpeg-devel] [PATCH v5 3/5] fftools: Provide a an fftools-specific logging callback function softworkz
2025-03-09 19:01 ` [FFmpeg-devel] [PATCH v5 4/5] doc/fftools-common-opts: document memaddresses log flag softworkz
2025-03-09 19:01 ` [FFmpeg-devel] [PATCH v5 5/5] Remove commented lines softworkz
2025-03-13 9:30 ` [FFmpeg-devel] [PATCH v6 0/3] avutil/log: Replace addresses in log output with simple ids ffmpegagent
2025-03-13 9:30 ` [FFmpeg-devel] [PATCH v6 1/3] fftools: Add a local logging callback function softworkz
2025-03-13 9:30 ` [FFmpeg-devel] [PATCH v6 2/3] fftools/opt_common: add memaddresses log flag softworkz
2025-03-13 9:30 ` [FFmpeg-devel] [PATCH v6 3/3] doc/fftools-common-opts: document " softworkz
2025-04-09 5:54 ` [FFmpeg-devel] [PATCH v7 0/3] avutil/log: Add log flag to control printing of memory addresses ffmpegagent
2025-04-09 5:55 ` [FFmpeg-devel] [PATCH v7 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES softworkz
2025-04-09 7:27 ` Andreas Rheinhardt
2025-04-09 7:50 ` softworkz .
2025-04-09 8:02 ` softworkz .
2025-04-09 8:11 ` Andreas Rheinhardt
2025-04-09 8:24 ` softworkz .
2025-04-09 8:27 ` Andreas Rheinhardt
2025-04-09 9:56 ` softworkz .
2025-04-09 8:15 ` Andreas Rheinhardt
2025-04-09 5:55 ` [FFmpeg-devel] [PATCH v7 2/3] fftools/opt_common: add memaddresses log flag softworkz
2025-04-09 5:55 ` [FFmpeg-devel] [PATCH v7 3/3] doc/fftools-common-opts: document " softworkz
2025-04-09 9:25 ` [FFmpeg-devel] [PATCH v8 0/3] avutil/log: Add log flag to control printing of memory addresses ffmpegagent
2025-04-09 9:25 ` [FFmpeg-devel] [PATCH v8 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES softworkz
2025-04-09 9:25 ` [FFmpeg-devel] [PATCH v8 2/3] fftools: add memaddress log flag and disable printing addresses by default softworkz
2025-04-09 14:28 ` Gyan Doshi
2025-04-09 14:41 ` softworkz .
2025-04-09 9:25 ` [FFmpeg-devel] [PATCH v8 3/3] doc/fftools-common-opts: document memaddress log flag softworkz
2025-04-09 18:19 ` [FFmpeg-devel] [PATCH v9 0/3] avutil/log: Add log flag to control printing of memory addresses ffmpegagent
2025-04-09 18:19 ` [FFmpeg-devel] [PATCH v9 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES softworkz
2025-04-09 18:19 ` [FFmpeg-devel] [PATCH v9 2/3] fftools: add mem log flag and disable printing addresses by default softworkz
2025-04-09 18:26 ` Gyan Doshi
2025-04-09 18:40 ` softworkz .
2025-04-09 18:19 ` [FFmpeg-devel] [PATCH v9 3/3] doc/fftools-common-opts: document mem log flag softworkz
2025-04-10 0:38 ` [FFmpeg-devel] [PATCH v10 0/3] avutil/log: Add log flag to control printing of memory addresses ffmpegagent
2025-04-10 0:38 ` [FFmpeg-devel] [PATCH v10 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES softworkz
2025-04-10 7:38 ` Andreas Rheinhardt
2025-04-10 18:06 ` softworkz .
2025-04-10 0:38 ` [FFmpeg-devel] [PATCH v10 2/3] fftools: add mem log flag and disable printing addresses by default softworkz
2025-04-10 6:51 ` Nicolas George
2025-04-10 18:02 ` softworkz .
2025-04-16 13:43 ` Michael Niedermayer
2025-04-16 13:50 ` Nicolas George
2025-04-16 14:25 ` Gyan Doshi
2025-04-16 14:26 ` softworkz .
2025-04-10 0:38 ` [FFmpeg-devel] [PATCH v10 3/3] doc/fftools-common-opts: document mem log flag softworkz
2025-06-06 20:29 ` [FFmpeg-devel] [PATCH v11 0/3] avutil/log: Add log flag to control printing of memory addresses ffmpegagent
2025-06-06 20:29 ` [FFmpeg-devel] [PATCH v11 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESS and hide addresses by default softworkz
2025-06-06 20:29 ` [FFmpeg-devel] [PATCH v11 2/3] fftools: add mem log flag for printing memory addresses softworkz
2025-06-06 20:29 ` [FFmpeg-devel] [PATCH v11 3/3] doc/fftools-common-opts: document mem log flag softworkz
2025-06-06 23:23 ` [FFmpeg-devel] [PATCH v11 0/3] avutil/log: Add log flag to control printing of memory addresses Kieran Kunhya via ffmpeg-devel
2025-06-06 23:26 ` softworkz .
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b8702de13b42e42940a3186060fed0a7a53455f9.1741294751.git.ffmpegagent@gmail.com \
--to=ffmpegagent@gmail.com \
--cc=ffmpeg-devel@ffmpeg.org \
--cc=softworkz@hotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git