Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 0/3] Add option to log timing
@ 2022-08-24 19:37 ffmpegagent
  2022-08-24 19:37 ` [FFmpeg-devel] [PATCH 1/3] avutil/log: support logging of date and timing information softworkz
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: ffmpegagent @ 2022-08-24 19:37 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: softworkz

This pathcset adds two logging flags: 'timing' and 'datetiming'.

Usage:

ffmpeg -loglevel +timing

or

ffmpeg -loglevel +datetiming

softworkz (3):
  avutil/log: support logging of date and timing information
  fftools/opt_common: add timing and datetiming log flags
  doc/fftools-common-opts: document log timing flags

 doc/APIchanges               |  3 +++
 doc/fftools-common-opts.texi |  4 ++++
 fftools/opt_common.c         | 12 ++++++++++++
 libavutil/log.c              | 32 +++++++++++++++++++++++++++++---
 libavutil/log.h              | 10 ++++++++++
 libavutil/version.h          |  4 ++--
 6 files changed, 60 insertions(+), 5 deletions(-)


base-commit: 48cb2c7a8a2deca40dd2f143848dd5addc25465c
Published-As: https://github.com/ffstaging/FFmpeg/releases/tag/pr-ffstaging-37%2Fsoftworkz%2Fsubmit_logtiming-v1
Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg pr-ffstaging-37/softworkz/submit_logtiming-v1
Pull-Request: https://github.com/ffstaging/FFmpeg/pull/37
-- 
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".

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [FFmpeg-devel] [PATCH 1/3] avutil/log: support logging of date and timing information
  2022-08-24 19:37 [FFmpeg-devel] [PATCH 0/3] Add option to log timing ffmpegagent
@ 2022-08-24 19:37 ` softworkz
  2022-08-24 19:37 ` [FFmpeg-devel] [PATCH 2/3] fftools/opt_common: add timing and datetiming log flags softworkz
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: softworkz @ 2022-08-24 19:37 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: softworkz

From: softworkz <softworkz@hotmail.com>

Signed-off-by: softworkz <softworkz@hotmail.com>
---
 doc/APIchanges      |  3 +++
 libavutil/log.c     | 32 +++++++++++++++++++++++++++++---
 libavutil/log.h     | 10 ++++++++++
 libavutil/version.h |  4 ++--
 4 files changed, 44 insertions(+), 5 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 4c0c9db628..eae5ba0525 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -14,6 +14,9 @@ libavutil:     2021-04-27
 
 API changes, most recent first:
 
+2022-08-xx - xxxxxxxxxx - lavu 57.34.100 - log.h
+  Add flags AV_LOG_PRINT_TIME and AV_LOG_PRINT_DATETIME.
+
 2022-08-xx - xxxxxxxxxx - lavf 59 - avformat.h
   Deprecate av_stream_get_end_pts() without replacement.
 
diff --git a/libavutil/log.c b/libavutil/log.c
index 5948e50467..15a43c1631 100644
--- a/libavutil/log.c
+++ b/libavutil/log.c
@@ -42,6 +42,8 @@
 #include "internal.h"
 #include "log.h"
 #include "thread.h"
+#include "time.h"
+#include "time_internal.h"
 
 static AVMutex mutex = AV_MUTEX_INITIALIZER;
 
@@ -291,14 +293,32 @@ static const char *get_level_str(int level)
     }
 }
 
+static void format_date_now(AVBPrint* timeBuf, int include_date)
+{
+    struct tm *ptm, tmbuf;
+    const int64_t time_us = av_gettime();
+    const int64_t time_ms = time_us / 1000;
+    const time_t time_s   = time_ms / 1000;
+    const int millisec    = time_ms - (time_s * 1000);
+    ptm                   = localtime_r(&time_s, &tmbuf);
+    if (ptm) {
+        if (include_date)
+            av_bprint_strftime(timeBuf, "%Y-%m-%d ", ptm);
+
+        av_bprint_strftime(timeBuf, "%H:%M:%S", ptm);
+        av_bprintf(timeBuf, ".%03d ", millisec);
+    }
+}
+
 static void format_line(void *avcl, int level, const char *fmt, va_list vl,
-                        AVBPrint part[4], int *print_prefix, int type[2])
+                        AVBPrint part[5], int *print_prefix, int type[2])
 {
     AVClass* avc = avcl ? *(AVClass **) avcl : NULL;
     av_bprint_init(part+0, 0, AV_BPRINT_SIZE_AUTOMATIC);
     av_bprint_init(part+1, 0, AV_BPRINT_SIZE_AUTOMATIC);
     av_bprint_init(part+2, 0, AV_BPRINT_SIZE_AUTOMATIC);
     av_bprint_init(part+3, 0, 65536);
+    av_bprint_init(part+4, 0, AV_BPRINT_SIZE_AUTOMATIC);
 
     if(type) type[0] = type[1] = AV_CLASS_CATEGORY_NA + 16;
     if (*print_prefix && avc) {
@@ -316,6 +336,9 @@ static void format_line(void *avcl, int level, const char *fmt, va_list vl,
         if(type) type[1] = get_category(avcl);
     }
 
+    if (*print_prefix && (flags & (AV_LOG_PRINT_TIME | AV_LOG_PRINT_DATETIME)))
+        format_date_now(&part[4], flags & AV_LOG_PRINT_DATETIME);
+
     if (*print_prefix && (level > AV_LOG_QUIET) && (flags & AV_LOG_PRINT_LEVEL))
         av_bprintf(part+2, "[%s] ", get_level_str(level));
 
@@ -336,7 +359,7 @@ void av_log_format_line(void *ptr, int level, const char *fmt, va_list vl,
 int av_log_format_line2(void *ptr, int level, const char *fmt, va_list vl,
                         char *line, int line_size, int *print_prefix)
 {
-    AVBPrint part[4];
+    AVBPrint part[5];
     int ret;
 
     format_line(ptr, level, fmt, vl, part, print_prefix, NULL);
@@ -350,7 +373,7 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
     static int print_prefix = 1;
     static int count;
     static char prev[LINE_SZ];
-    AVBPrint part[4];
+    AVBPrint part[5];
     char line[LINE_SZ];
     static int is_atty;
     int type[2];
@@ -385,6 +408,9 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
         count = 0;
     }
     strcpy(prev, line);
+
+    sanitize(part[4].str);
+    colored_fputs(7, 0, part[4].str);
     sanitize(part[0].str);
     colored_fputs(type[0], 0, part[0].str);
     sanitize(part[1].str);
diff --git a/libavutil/log.h b/libavutil/log.h
index ab7ceabe22..8336f65b16 100644
--- a/libavutil/log.h
+++ b/libavutil/log.h
@@ -377,6 +377,16 @@ int av_log_format_line2(void *ptr, int level, const char *fmt, va_list vl,
  */
 #define AV_LOG_PRINT_LEVEL 2
 
+/**
+ * Include system time in log output.
+ */
+#define AV_LOG_PRINT_TIME 4
+
+/**
+ * Include system date and time in log output.
+ */
+#define AV_LOG_PRINT_DATETIME 8
+
 void av_log_set_flags(int arg);
 int av_log_get_flags(void);
 
diff --git a/libavutil/version.h b/libavutil/version.h
index 05661922b3..5d0df781cc 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,8 +79,8 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  57
-#define LIBAVUTIL_VERSION_MINOR  33
-#define LIBAVUTIL_VERSION_MICRO 101
+#define LIBAVUTIL_VERSION_MINOR  34
+#define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
                                                LIBAVUTIL_VERSION_MINOR, \
-- 
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".

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [FFmpeg-devel] [PATCH 2/3] fftools/opt_common: add timing and datetiming log flags
  2022-08-24 19:37 [FFmpeg-devel] [PATCH 0/3] Add option to log timing ffmpegagent
  2022-08-24 19:37 ` [FFmpeg-devel] [PATCH 1/3] avutil/log: support logging of date and timing information softworkz
@ 2022-08-24 19:37 ` softworkz
  2022-08-24 19:37 ` [FFmpeg-devel] [PATCH 3/3] doc/fftools-common-opts: document log timing flags softworkz
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: softworkz @ 2022-08-24 19:37 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: softworkz

From: softworkz <softworkz@hotmail.com>

This commit adds two logging flags: 'timing' and 'datetiming'.

Usage:

ffmpeg -loglevel +timing

or

ffmpeg -loglevel +datetiming

Signed-off-by: softworkz <softworkz@hotmail.com>
---
 fftools/opt_common.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/fftools/opt_common.c b/fftools/opt_common.c
index ae5e28a5af..bd8430751c 100644
--- a/fftools/opt_common.c
+++ b/fftools/opt_common.c
@@ -1268,6 +1268,18 @@ int opt_loglevel(void *optctx, const char *opt, const char *arg)
             } else {
                 flags |= AV_LOG_PRINT_LEVEL;
             }
+        } else if (av_strstart(token, "timing", &arg)) {
+            if (cmd == '-') {
+                flags &= ~AV_LOG_PRINT_TIME;
+            } else {
+                flags |= AV_LOG_PRINT_TIME;
+            }
+        } else if (av_strstart(token, "datetiming", &arg)) {
+            if (cmd == '-') {
+                flags &= ~AV_LOG_PRINT_DATETIME;
+            } else {
+                flags |= AV_LOG_PRINT_DATETIME;
+            }
         } else {
             break;
         }
-- 
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".

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [FFmpeg-devel] [PATCH 3/3] doc/fftools-common-opts: document log timing flags
  2022-08-24 19:37 [FFmpeg-devel] [PATCH 0/3] Add option to log timing ffmpegagent
  2022-08-24 19:37 ` [FFmpeg-devel] [PATCH 1/3] avutil/log: support logging of date and timing information softworkz
  2022-08-24 19:37 ` [FFmpeg-devel] [PATCH 2/3] fftools/opt_common: add timing and datetiming log flags softworkz
@ 2022-08-24 19:37 ` softworkz
  2022-12-12 23:10 ` [FFmpeg-devel] [PATCH 0/3] Add option to log timing Soft Works
  2025-01-30  3:53 ` [FFmpeg-devel] [PATCH v2 " ffmpegagent
  4 siblings, 0 replies; 11+ messages in thread
From: softworkz @ 2022-08-24 19:37 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: softworkz

From: softworkz <softworkz@hotmail.com>

Signed-off-by: softworkz <softworkz@hotmail.com>
---
 doc/fftools-common-opts.texi | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/doc/fftools-common-opts.texi b/doc/fftools-common-opts.texi
index d9145704d6..eee3b6ead0 100644
--- a/doc/fftools-common-opts.texi
+++ b/doc/fftools-common-opts.texi
@@ -201,6 +201,10 @@ and the "Last message repeated n times" line will be omitted.
 Indicates that log output should add a @code{[level]} prefix to each message
 line. This can be used as an alternative to log coloring, e.g. when dumping the
 log to file.
+@item timing
+Indicates that log lines should be prefixed with timing information.
+@item datetiming
+Indicates that log lines should be prefixed with date and timing information.
 @end table
 Flags can also be used alone by adding a '+'/'-' prefix to set/reset a single
 flag without affecting other @var{flags} or changing @var{loglevel}. When
-- 
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".

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [FFmpeg-devel] [PATCH 0/3] Add option to log timing
  2022-08-24 19:37 [FFmpeg-devel] [PATCH 0/3] Add option to log timing ffmpegagent
                   ` (2 preceding siblings ...)
  2022-08-24 19:37 ` [FFmpeg-devel] [PATCH 3/3] doc/fftools-common-opts: document log timing flags softworkz
@ 2022-12-12 23:10 ` Soft Works
  2025-01-30  3:53 ` [FFmpeg-devel] [PATCH v2 " ffmpegagent
  4 siblings, 0 replies; 11+ messages in thread
From: Soft Works @ 2022-12-12 23:10 UTC (permalink / raw)
  To: ffmpegagent, ffmpeg-devel

Ping again

Thanks

> -----Original Message-----
> From: ffmpegagent <ffmpegagent@gmail.com>
> Sent: Wednesday, August 24, 2022 9:38 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: softworkz <softworkz@hotmail.com>
> Subject: [PATCH 0/3] Add option to log timing
> 
> This pathcset adds two logging flags: 'timing' and 'datetiming'.
> 
> Usage:
> 
> ffmpeg -loglevel +timing
> 
> or
> 
> ffmpeg -loglevel +datetiming
> 
> softworkz (3):
>   avutil/log: support logging of date and timing information
>   fftools/opt_common: add timing and datetiming log flags
>   doc/fftools-common-opts: document log timing flags
> 
>  doc/APIchanges               |  3 +++
>  doc/fftools-common-opts.texi |  4 ++++
>  fftools/opt_common.c         | 12 ++++++++++++
>  libavutil/log.c              | 32 +++++++++++++++++++++++++++++---
>  libavutil/log.h              | 10 ++++++++++
>  libavutil/version.h          |  4 ++--
>  6 files changed, 60 insertions(+), 5 deletions(-)
> 
> 
> base-commit: 48cb2c7a8a2deca40dd2f143848dd5addc25465c
> Published-As: https://github.com/ffstaging/FFmpeg/releases/tag/pr-
> ffstaging-37%2Fsoftworkz%2Fsubmit_logtiming-v1
> Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg pr-
> ffstaging-37/softworkz/submit_logtiming-v1
> Pull-Request: https://github.com/ffstaging/FFmpeg/pull/37
> --
> 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".

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [FFmpeg-devel] [PATCH v2 0/3] Add option to log timing
  2022-08-24 19:37 [FFmpeg-devel] [PATCH 0/3] Add option to log timing ffmpegagent
                   ` (3 preceding siblings ...)
  2022-12-12 23:10 ` [FFmpeg-devel] [PATCH 0/3] Add option to log timing Soft Works
@ 2025-01-30  3:53 ` ffmpegagent
  2025-01-30  3:53   ` [FFmpeg-devel] [PATCH v2 1/3] avutil/log: support logging of date and timing information softworkz
                     ` (2 more replies)
  4 siblings, 3 replies; 11+ messages in thread
From: ffmpegagent @ 2025-01-30  3:53 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: softworkz

This pathcset adds two logging flags: 'timing' and 'datetiming'.

Usage:

ffmpeg -loglevel +timing

or

ffmpeg -loglevel +datetiming

Update V2

 * Fix merge conflicts

Update V3

 * Rebased

softworkz (3):
  avutil/log: support logging of date and timing information
  fftools/opt_common: add timing and datetiming log flags
  doc/fftools-common-opts: document log timing flags

 doc/APIchanges               |  3 +++
 doc/fftools-common-opts.texi |  4 ++++
 fftools/opt_common.c         | 12 ++++++++++++
 libavutil/log.c              | 32 +++++++++++++++++++++++++++++---
 libavutil/log.h              | 10 ++++++++++
 libavutil/version.h          |  2 +-
 6 files changed, 59 insertions(+), 4 deletions(-)


base-commit: 4ba9ae7742a6f8a29d6486e25ff5709a075edb5b
Published-As: https://github.com/ffstaging/FFmpeg/releases/tag/pr-ffstaging-37%2Fsoftworkz%2Fsubmit_logtiming-v2
Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg pr-ffstaging-37/softworkz/submit_logtiming-v2
Pull-Request: https://github.com/ffstaging/FFmpeg/pull/37

Range-diff vs v1:

 1:  5dc718cfd5 ! 1:  13a7dc164b avutil/log: support logging of date and timing information
     @@ Commit message
          Signed-off-by: softworkz <softworkz@hotmail.com>
      
       ## doc/APIchanges ##
     -@@ doc/APIchanges: libavutil:     2021-04-27
     +@@ doc/APIchanges: The last version increases of all libraries were on 2024-03-07
       
       API changes, most recent first:
       
     -+2022-08-xx - xxxxxxxxxx - lavu 57.34.100 - log.h
     ++2025-01-xx - xxxxxxxxxx - lavu 59.57.100 - log.h
      +  Add flags AV_LOG_PRINT_TIME and AV_LOG_PRINT_DATETIME.
      +
     - 2022-08-xx - xxxxxxxxxx - lavf 59 - avformat.h
     -   Deprecate av_stream_get_end_pts() without replacement.
     + 2025-01-25 - xxxxxxxxxx - lavu 59.56.100 - frame.h
     +   Add AV_SIDE_DATA_PROP_CHANNEL_DEPENDENT.
       
      
       ## libavutil/log.c ##
     @@ libavutil/log.c
       
       static AVMutex mutex = AV_MUTEX_INITIALIZER;
       
     -@@ libavutil/log.c: static const char *get_level_str(int level)
     -     }
     +@@ libavutil/log.c: static const char *item_name(void *obj, const AVClass *cls)
     +     return (cls->item_name ? cls->item_name : av_default_item_name)(obj);
       }
       
      +static void format_date_now(AVBPrint* timeBuf, int include_date)
     @@ libavutil/version.h
      @@
        */
       
     - #define LIBAVUTIL_VERSION_MAJOR  57
     --#define LIBAVUTIL_VERSION_MINOR  33
     --#define LIBAVUTIL_VERSION_MICRO 101
     -+#define LIBAVUTIL_VERSION_MINOR  34
     -+#define LIBAVUTIL_VERSION_MICRO 100
     + #define LIBAVUTIL_VERSION_MAJOR  59
     +-#define LIBAVUTIL_VERSION_MINOR  56
     ++#define LIBAVUTIL_VERSION_MINOR  57
     + #define LIBAVUTIL_VERSION_MICRO 100
       
       #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
     -                                                LIBAVUTIL_VERSION_MINOR, \
 2:  23f6cad25e = 2:  9eb9a6cf48 fftools/opt_common: add timing and datetiming log flags
 3:  595d03037f = 3:  20e049c4c7 doc/fftools-common-opts: document log timing flags

-- 
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".

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [FFmpeg-devel] [PATCH v2 1/3] avutil/log: support logging of date and timing information
  2025-01-30  3:53 ` [FFmpeg-devel] [PATCH v2 " ffmpegagent
@ 2025-01-30  3:53   ` softworkz
  2025-01-30  3:53   ` [FFmpeg-devel] [PATCH v2 2/3] fftools/opt_common: add timing and datetiming log flags softworkz
  2025-01-30  3:53   ` [FFmpeg-devel] [PATCH v2 3/3] doc/fftools-common-opts: document log timing flags softworkz
  2 siblings, 0 replies; 11+ messages in thread
From: softworkz @ 2025-01-30  3:53 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: softworkz

From: softworkz <softworkz@hotmail.com>

Signed-off-by: softworkz <softworkz@hotmail.com>
---
 doc/APIchanges      |  3 +++
 libavutil/log.c     | 32 +++++++++++++++++++++++++++++---
 libavutil/log.h     | 10 ++++++++++
 libavutil/version.h |  2 +-
 4 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 0f2b640601..83d57ae314 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07
 
 API changes, most recent first:
 
+2025-01-xx - xxxxxxxxxx - lavu 59.57.100 - log.h
+  Add flags AV_LOG_PRINT_TIME and AV_LOG_PRINT_DATETIME.
+
 2025-01-25 - xxxxxxxxxx - lavu 59.56.100 - frame.h
   Add AV_SIDE_DATA_PROP_CHANNEL_DEPENDENT.
 
diff --git a/libavutil/log.c b/libavutil/log.c
index 46662f3db0..3ea6cb671e 100644
--- a/libavutil/log.c
+++ b/libavutil/log.c
@@ -42,6 +42,8 @@
 #include "internal.h"
 #include "log.h"
 #include "thread.h"
+#include "time.h"
+#include "time_internal.h"
 
 static AVMutex mutex = AV_MUTEX_INITIALIZER;
 
@@ -296,14 +298,32 @@ static const char *item_name(void *obj, const AVClass *cls)
     return (cls->item_name ? cls->item_name : av_default_item_name)(obj);
 }
 
+static void format_date_now(AVBPrint* timeBuf, int include_date)
+{
+    struct tm *ptm, tmbuf;
+    const int64_t time_us = av_gettime();
+    const int64_t time_ms = time_us / 1000;
+    const time_t time_s   = time_ms / 1000;
+    const int millisec    = time_ms - (time_s * 1000);
+    ptm                   = localtime_r(&time_s, &tmbuf);
+    if (ptm) {
+        if (include_date)
+            av_bprint_strftime(timeBuf, "%Y-%m-%d ", ptm);
+
+        av_bprint_strftime(timeBuf, "%H:%M:%S", ptm);
+        av_bprintf(timeBuf, ".%03d ", millisec);
+    }
+}
+
 static void format_line(void *avcl, int level, const char *fmt, va_list vl,
-                        AVBPrint part[4], int *print_prefix, int type[2])
+                        AVBPrint part[5], int *print_prefix, int type[2])
 {
     AVClass* avc = avcl ? *(AVClass **) avcl : NULL;
     av_bprint_init(part+0, 0, AV_BPRINT_SIZE_AUTOMATIC);
     av_bprint_init(part+1, 0, AV_BPRINT_SIZE_AUTOMATIC);
     av_bprint_init(part+2, 0, AV_BPRINT_SIZE_AUTOMATIC);
     av_bprint_init(part+3, 0, 65536);
+    av_bprint_init(part+4, 0, AV_BPRINT_SIZE_AUTOMATIC);
 
     if(type) type[0] = type[1] = AV_CLASS_CATEGORY_NA + 16;
     if (*print_prefix && avc) {
@@ -321,6 +341,9 @@ static void format_line(void *avcl, int level, const char *fmt, va_list vl,
         if(type) type[1] = get_category(avcl);
     }
 
+    if (*print_prefix && (flags & (AV_LOG_PRINT_TIME | AV_LOG_PRINT_DATETIME)))
+        format_date_now(&part[4], flags & AV_LOG_PRINT_DATETIME);
+
     if (*print_prefix && (level > AV_LOG_QUIET) && (flags & AV_LOG_PRINT_LEVEL))
         av_bprintf(part+2, "[%s] ", get_level_str(level));
 
@@ -341,7 +364,7 @@ void av_log_format_line(void *ptr, int level, const char *fmt, va_list vl,
 int av_log_format_line2(void *ptr, int level, const char *fmt, va_list vl,
                         char *line, int line_size, int *print_prefix)
 {
-    AVBPrint part[4];
+    AVBPrint part[5];
     int ret;
 
     format_line(ptr, level, fmt, vl, part, print_prefix, NULL);
@@ -355,7 +378,7 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
     static int print_prefix = 1;
     static int count;
     static char prev[LINE_SZ];
-    AVBPrint part[4];
+    AVBPrint part[5];
     char line[LINE_SZ];
     static int is_atty;
     int type[2];
@@ -390,6 +413,9 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
         count = 0;
     }
     strcpy(prev, line);
+
+    sanitize(part[4].str);
+    colored_fputs(7, 0, part[4].str);
     sanitize(part[0].str);
     colored_fputs(type[0], 0, part[0].str);
     sanitize(part[1].str);
diff --git a/libavutil/log.h b/libavutil/log.h
index 4c8c92266f..dd094307ce 100644
--- a/libavutil/log.h
+++ b/libavutil/log.h
@@ -406,6 +406,16 @@ int av_log_format_line2(void *ptr, int level, const char *fmt, va_list vl,
  */
 #define AV_LOG_PRINT_LEVEL 2
 
+/**
+ * Include system time in log output.
+ */
+#define AV_LOG_PRINT_TIME 4
+
+/**
+ * Include system date and time in log output.
+ */
+#define AV_LOG_PRINT_DATETIME 8
+
 void av_log_set_flags(int arg);
 int av_log_get_flags(void);
 
diff --git a/libavutil/version.h b/libavutil/version.h
index 83b7822125..ee4a36cb17 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  59
-#define LIBAVUTIL_VERSION_MINOR  56
+#define LIBAVUTIL_VERSION_MINOR  57
 #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".

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [FFmpeg-devel] [PATCH v2 2/3] fftools/opt_common: add timing and datetiming log flags
  2025-01-30  3:53 ` [FFmpeg-devel] [PATCH v2 " ffmpegagent
  2025-01-30  3:53   ` [FFmpeg-devel] [PATCH v2 1/3] avutil/log: support logging of date and timing information softworkz
@ 2025-01-30  3:53   ` softworkz
  2025-02-02  1:13     ` Michael Niedermayer
  2025-01-30  3:53   ` [FFmpeg-devel] [PATCH v2 3/3] doc/fftools-common-opts: document log timing flags softworkz
  2 siblings, 1 reply; 11+ messages in thread
From: softworkz @ 2025-01-30  3:53 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: softworkz

From: softworkz <softworkz@hotmail.com>

This commit adds two logging flags: 'timing' and 'datetiming'.

Usage:

ffmpeg -loglevel +timing

or

ffmpeg -loglevel +datetiming

Signed-off-by: softworkz <softworkz@hotmail.com>
---
 fftools/opt_common.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/fftools/opt_common.c b/fftools/opt_common.c
index 34da2cee7d..94e9dae8b6 100644
--- a/fftools/opt_common.c
+++ b/fftools/opt_common.c
@@ -1292,6 +1292,18 @@ int opt_loglevel(void *optctx, const char *opt, const char *arg)
             } else {
                 flags |= AV_LOG_PRINT_LEVEL;
             }
+        } else if (av_strstart(token, "timing", &arg)) {
+            if (cmd == '-') {
+                flags &= ~AV_LOG_PRINT_TIME;
+            } else {
+                flags |= AV_LOG_PRINT_TIME;
+            }
+        } else if (av_strstart(token, "datetiming", &arg)) {
+            if (cmd == '-') {
+                flags &= ~AV_LOG_PRINT_DATETIME;
+            } else {
+                flags |= AV_LOG_PRINT_DATETIME;
+            }
         } else {
             break;
         }
-- 
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".

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [FFmpeg-devel] [PATCH v2 3/3] doc/fftools-common-opts: document log timing flags
  2025-01-30  3:53 ` [FFmpeg-devel] [PATCH v2 " ffmpegagent
  2025-01-30  3:53   ` [FFmpeg-devel] [PATCH v2 1/3] avutil/log: support logging of date and timing information softworkz
  2025-01-30  3:53   ` [FFmpeg-devel] [PATCH v2 2/3] fftools/opt_common: add timing and datetiming log flags softworkz
@ 2025-01-30  3:53   ` softworkz
  2 siblings, 0 replies; 11+ messages in thread
From: softworkz @ 2025-01-30  3:53 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: softworkz

From: softworkz <softworkz@hotmail.com>

Signed-off-by: softworkz <softworkz@hotmail.com>
---
 doc/fftools-common-opts.texi | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/doc/fftools-common-opts.texi b/doc/fftools-common-opts.texi
index 8b0931a86d..37bed92864 100644
--- a/doc/fftools-common-opts.texi
+++ b/doc/fftools-common-opts.texi
@@ -226,6 +226,10 @@ and the "Last message repeated n times" line will be omitted.
 Indicates that log output should add a @code{[level]} prefix to each message
 line. This can be used as an alternative to log coloring, e.g. when dumping the
 log to file.
+@item timing
+Indicates that log lines should be prefixed with timing information.
+@item datetiming
+Indicates that log lines should be prefixed with date and timing information.
 @end table
 Flags can also be used alone by adding a '+'/'-' prefix to set/reset a single
 flag without affecting other @var{flags} or changing @var{loglevel}. When
-- 
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".

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [FFmpeg-devel] [PATCH v2 2/3] fftools/opt_common: add timing and datetiming log flags
  2025-01-30  3:53   ` [FFmpeg-devel] [PATCH v2 2/3] fftools/opt_common: add timing and datetiming log flags softworkz
@ 2025-02-02  1:13     ` Michael Niedermayer
  2025-02-02  1:38       ` Soft Works
  0 siblings, 1 reply; 11+ messages in thread
From: Michael Niedermayer @ 2025-02-02  1:13 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 764 bytes --]

Hi softworkz

On Thu, Jan 30, 2025 at 03:53:25AM +0000, softworkz wrote:
> From: softworkz <softworkz@hotmail.com>
> 
> This commit adds two logging flags: 'timing' and 'datetiming'.
> 
> Usage:
> 
> ffmpeg -loglevel +timing
> 
> or
> 
> ffmpeg -loglevel +datetiming


./ffmpeg -loglevel +timing
...
02:04:00.926 Use -h to get full help or, even better, run 'man ffmpeg'
02:04:00.926 michael@box:~/ffmpeg/$

It seems the shell command prompt is after the last time
is this intended ?

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Take away the freedom of one citizen and you will be jailed, take away
the freedom of all citizens and you will be congratulated by your peers
in Parliament.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [FFmpeg-devel] [PATCH v2 2/3] fftools/opt_common: add timing and datetiming log flags
  2025-02-02  1:13     ` Michael Niedermayer
@ 2025-02-02  1:38       ` Soft Works
  0 siblings, 0 replies; 11+ messages in thread
From: Soft Works @ 2025-02-02  1:38 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Hi Michael,

thanks a lot for looking at this.


> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> Michael Niedermayer
> Sent: Sunday, February 2, 2025 2:14 AM
> To: FFmpeg development discussions and patches <ffmpeg-
> devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH v2 2/3] fftools/opt_common: add
> timing and datetiming log flags
> 
> Hi softworkz
> 
> On Thu, Jan 30, 2025 at 03:53:25AM +0000, softworkz wrote:
> > From: softworkz <softworkz@hotmail.com>
> >
> > This commit adds two logging flags: 'timing' and 'datetiming'.
> >
> > Usage:
> >
> > ffmpeg -loglevel +timing
> >
> > or
> >
> > ffmpeg -loglevel +datetiming
> 
> 
> ./ffmpeg -loglevel +timing
> ...
> 02:04:00.926 Use -h to get full help or, even better, run 'man
> ffmpeg'
> 02:04:00.926 michael@box:~/ffmpeg/$
> 
> It seems the shell command prompt is after the last time
> is this intended ?

Of course not 😊
Where it's in use, I had also added printing of the word "EXIT" before exiting (to easily recognize crashed or killed vs regular terminations), that's probably why I've never seen this.

Will submit an update,
thank you very much,
sw

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2025-02-02  1:38 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-24 19:37 [FFmpeg-devel] [PATCH 0/3] Add option to log timing ffmpegagent
2022-08-24 19:37 ` [FFmpeg-devel] [PATCH 1/3] avutil/log: support logging of date and timing information softworkz
2022-08-24 19:37 ` [FFmpeg-devel] [PATCH 2/3] fftools/opt_common: add timing and datetiming log flags softworkz
2022-08-24 19:37 ` [FFmpeg-devel] [PATCH 3/3] doc/fftools-common-opts: document log timing flags softworkz
2022-12-12 23:10 ` [FFmpeg-devel] [PATCH 0/3] Add option to log timing Soft Works
2025-01-30  3:53 ` [FFmpeg-devel] [PATCH v2 " ffmpegagent
2025-01-30  3:53   ` [FFmpeg-devel] [PATCH v2 1/3] avutil/log: support logging of date and timing information softworkz
2025-01-30  3:53   ` [FFmpeg-devel] [PATCH v2 2/3] fftools/opt_common: add timing and datetiming log flags softworkz
2025-02-02  1:13     ` Michael Niedermayer
2025-02-02  1:38       ` Soft Works
2025-01-30  3:53   ` [FFmpeg-devel] [PATCH v2 3/3] doc/fftools-common-opts: document log timing flags softworkz

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