diff mbox series

[FFmpeg-devel,v4,1/2] libavutil/log: Add capability to prefix loglines with current time or current date+time

Message ID MN2PR04MB5981BA2344855E514EE80881BAF69@MN2PR04MB5981.namprd04.prod.outlook.com
State Superseded, archived
Headers show
Series [FFmpeg-devel,v4,1/2] libavutil/log: Add capability to prefix loglines with current time or current date+time | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Soft Works Aug. 9, 2021, 2:15 a.m. UTC
Signed-off-by: softworkz <softworkz@hotmail.com>
---
v2: split commits differently, fix AVBPrint finalization
 doc/APIchanges      |  3 +++
 libavutil/log.c     | 33 ++++++++++++++++++++++++++++++---
 libavutil/log.h     | 10 ++++++++++
 libavutil/version.h |  2 +-
 4 files changed, 44 insertions(+), 4 deletions(-)

Comments

Nicolas George Aug. 9, 2021, 8:28 a.m. UTC | #1
Soft Works (12021-08-09):
> Signed-off-by: softworkz <softworkz@hotmail.com>
> ---
> v2: split commits differently, fix AVBPrint finalization
>  doc/APIchanges      |  3 +++
>  libavutil/log.c     | 33 ++++++++++++++++++++++++++++++---
>  libavutil/log.h     | 10 ++++++++++
>  libavutil/version.h |  2 +-
>  4 files changed, 44 insertions(+), 4 deletions(-)
> 
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 6eefc7fc33..be707314f3 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -14,6 +14,9 @@ libavutil:     2021-04-27
>  
>  API changes, most recent first:
>  
> +2021-08-09 - xxxxxxxxxx - lavu 57.4.100 - log.h
> +  Add new defines: AV_LOG_PRINT_TIME and AV_LOG_PRINT_DATETIME
> +
>  2021-08-02 - xxxxxxxxxx - lavc 59.4.100 - packet.h
>    Add AVPacket.opaque, AVPacket.opaque_ref, AVPacket.time_base.
>  
> diff --git a/libavutil/log.c b/libavutil/log.c
> index 66defa9c42..f29533a91f 100644
> --- a/libavutil/log.c
> +++ b/libavutil/log.c
> @@ -40,6 +40,8 @@
>  #include "internal.h"
>  #include "log.h"
>  #include "thread.h"
> +#include "time.h"
> +#include "time_internal.h"
>  
>  static AVMutex mutex = AV_MUTEX_INITIALIZER;
>  
> @@ -289,14 +291,32 @@ static const char *get_level_str(int level)
>      }
>  }
>  

> +static void format_date_now(AVBPrint* timeBuf, int include_date)

Pointer mark belongs with the variable, not with the type. Even if the
surrounding code is wrong too.

> +{
> +    struct tm *ptm, tmbuf;

> +    int64_t time_us = av_gettime();
> +    int64_t time_ms = time_us / 1000;

You can merge these two lines, since time_us is used only there.

> +    const time_t time_s = time_ms / 1000;
> +    int millisec = time_ms - (time_s * 1000);

Using % would probably be more easily optimized by compilers.

> +    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);

Are we ok printing a local time without a time zone?

> +        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) {
> @@ -314,6 +334,10 @@ 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) || (flags & AV_LOG_PRINT_DATETIME)))

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));
>  
> @@ -334,7 +358,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);
> @@ -348,7 +372,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];
> @@ -383,6 +407,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);

Not really necessary.

> +    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 8727c38afc..27eb071884 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.

"local time"

> + */
> +#define AV_LOG_PRINT_TIME 4
> +
> +/**

> + * Include system date and time in log output.

Ditto.

> + */
> +#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 6b4a265457..201b012596 100644
> --- a/libavutil/version.h
> +++ b/libavutil/version.h
> @@ -79,7 +79,7 @@
>   */
>  
>  #define LIBAVUTIL_VERSION_MAJOR  57
> -#define LIBAVUTIL_VERSION_MINOR   3
> +#define LIBAVUTIL_VERSION_MINOR   4
>  #define LIBAVUTIL_VERSION_MICRO 100
>  
>  #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \

Regards,
Soft Works Aug. 10, 2021, 9:04 a.m. UTC | #2
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> Nicolas George
> Sent: Monday, 9 August 2021 10:28
> To: FFmpeg development discussions and patches <ffmpeg-
> devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH v4 1/2] libavutil/log: Add capability to
> prefix loglines with current time or current date+time
> 
> Soft Works (12021-08-09):
> > Signed-off-by: softworkz <softworkz@hotmail.com>
> > ---
> > v2: split commits differently, fix AVBPrint finalization
> >  doc/APIchanges      |  3 +++
> >  libavutil/log.c     | 33 ++++++++++++++++++++++++++++++---
> >  libavutil/log.h     | 10 ++++++++++
> >  libavutil/version.h |  2 +-
> >  4 files changed, 44 insertions(+), 4 deletions(-)

Hi Nicholas,

I'm not sure whether it's OK to strip all content when there's nothing
new inside..?

I made all of your suggested changes. 
Thanks a lot for your review.

softworkz
Nicolas George Aug. 10, 2021, 9:06 a.m. UTC | #3
Soft Works (12021-08-10):
> I'm not sure whether it's OK to strip all content when there's nothing
> new inside..?

I do not understand what you are talking about, sorry.

Regards,
Soft Works Aug. 10, 2021, 9:07 a.m. UTC | #4
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> Nicolas George
> Sent: Tuesday, 10 August 2021 11:06
> To: FFmpeg development discussions and patches <ffmpeg-
> devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH v4 1/2] libavutil/log: Add capability to
> prefix loglines with current time or current date+time
> 
> Soft Works (12021-08-10):
> > I'm not sure whether it's OK to strip all content when there's nothing
> > new inside..?
> 
> I do not understand what you are talking about, sorry.

I meant the e-mail body of the previous conversation.
Nicolas George Aug. 10, 2021, 9:16 a.m. UTC | #5
Soft Works (12021-08-10):
> I meant the e-mail body of the previous conversation.

Well, it is my mail, I put what I want in it, and you do what you want
with yours.

But ask yourself: which one do you find easier to read: one where you
have to scroll half a dozen pages of old mail just to get to the new
bits, or one where you have enough quoted context to remember what the
discussion is about but not too much?

For me, the answer is the second, and since I prefer this for myself I
have toe courtesy to do the same for the mails I send, even if it takes
a few more keystrokes. A lot of people do not bother, and even many more
people bother even less and top-post.

Compare with a hand-written letter: you would never copy all the missive
you are replying to, you would just quote a little bit to give context,
“regarding you calling on me tomorrow”…

The full context is always available in mail archives, of course, nobody
can prevent that, especially if you have full archives of your own
somewhere.

Regards,
Soft Works Aug. 10, 2021, 9:47 a.m. UTC | #6
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> Nicolas George
> Sent: Tuesday, 10 August 2021 11:16
> To: FFmpeg development discussions and patches <ffmpeg-
> devel@ffmpeg.org>
> Subject: [FFmpeg-devel] Mail quoting (was: 1/2] libavutil/log: Add capability
> to prefix loglines with current time or current date+time)
> 
> Soft Works (12021-08-10):
> > I meant the e-mail body of the previous conversation.
> 
> Well, it is my mail, I put what I want in it, and you do what you want with
> yours.
> 
> But ask yourself: which one do you find easier to read: one where you have
> to scroll half a dozen pages of old mail just to get to the new bits, or one
> where you have enough quoted context to remember what the discussion is
> about but not too much?
> 
> For me, the answer is the second, and since I prefer this for myself

Totally agree.

> I have toe
> courtesy to do the same for the mails I send, even if it takes a few more
> keystrokes. A lot of people do not bother, 

Yes, that made me wonder whether shortening would be against any rule or 
guideline.

One of the most annoying things with that mailing-list-style development
is the requirement to scroll through every single message of concern 
while trying to spot all lines that do not have a '> ' prefix. As some do not 
even put a blank line before and after a comment, you cannot rely on that,
meaning that you have to look very carefully while scrolling.

It's surely OK for regular conversations, but for working with code...

Kind regards,
softworkz
Michael Niedermayer Aug. 10, 2021, 2:02 p.m. UTC | #7
On Tue, Aug 10, 2021 at 09:47:31AM +0000, Soft Works wrote:
> 
> 
> > -----Original Message-----
> > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> > Nicolas George
> > Sent: Tuesday, 10 August 2021 11:16
> > To: FFmpeg development discussions and patches <ffmpeg-
> > devel@ffmpeg.org>
> > Subject: [FFmpeg-devel] Mail quoting (was: 1/2] libavutil/log: Add capability
> > to prefix loglines with current time or current date+time)
> > 
> > Soft Works (12021-08-10):
> > > I meant the e-mail body of the previous conversation.
> > 
> > Well, it is my mail, I put what I want in it, and you do what you want with
> > yours.
> > 
> > But ask yourself: which one do you find easier to read: one where you have
> > to scroll half a dozen pages of old mail just to get to the new bits, or one
> > where you have enough quoted context to remember what the discussion is
> > about but not too much?
> > 
> > For me, the answer is the second, and since I prefer this for myself
> 
> Totally agree.
> 
> > I have toe
> > courtesy to do the same for the mails I send, even if it takes a few more
> > keystrokes. A lot of people do not bother, 
> 
> Yes, that made me wonder whether shortening would be against any rule or 
> guideline.
> 
> One of the most annoying things with that mailing-list-style development
> is the requirement to scroll through every single message of concern 
> while trying to spot all lines that do not have a '> ' prefix. As some do not 
> even put a blank line before and after a comment, you cannot rely on that,
> meaning that you have to look very carefully while scrolling.

if your MUA doesnt color the text to make it easy, 
maybe you should consider a different MUA
for example mutt can color code text based on how many ">" are there at the begin
in fact mutt lets you write your own rules for how to color the mails
I would assume any half decent MUA should be able to do something similar

Thanks

[...]
Nicolas George Aug. 10, 2021, 2:28 p.m. UTC | #8
Michael Niedermayer (12021-08-10):
> if your MUA doesnt color the text to make it easy, 
> maybe you should consider a different MUA

This is good advice in this specific instance, but I would not consider
it an excuse for myself not to properly trim the replies I make, on the
principle that I should not demand many people to change their habits
just to accommodate mine.

A little effort by one person is better than a tiny effort by many.

> for example mutt can color code text based on how many ">" are there at the begin
> in fact mutt lets you write your own rules for how to color the mails
> I would assume any half decent MUA should be able to do something similar

Mutt also has a short-cut (S by default) to skip until the first line of
non-quoted text. It is a life-saver when you all do not trim your mails.

Regards,
Soft Works Aug. 10, 2021, 2:30 p.m. UTC | #9
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Michael
> Niedermayer
> Sent: Tuesday, 10 August 2021 16:03
> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] Mail quoting (was: 1/2] libavutil/log: Add
> capability to prefix loglines with current time or current date+time)
> 
> On Tue, Aug 10, 2021 at 09:47:31AM +0000, Soft Works wrote:
> >
> >
> > > -----Original Message-----
> > > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> > > Nicolas George
> > > Sent: Tuesday, 10 August 2021 11:16
> > > To: FFmpeg development discussions and patches <ffmpeg-
> > > devel@ffmpeg.org>
> > > Subject: [FFmpeg-devel] Mail quoting (was: 1/2] libavutil/log: Add
> capability
> > > to prefix loglines with current time or current date+time)
> > >
> > > Soft Works (12021-08-10):
> > > > I meant the e-mail body of the previous conversation.
> > >
> > > Well, it is my mail, I put what I want in it, and you do what you want
> with
> > > yours.
> > >
> > > But ask yourself: which one do you find easier to read: one where you
> have
> > > to scroll half a dozen pages of old mail just to get to the new bits,
> or one
> > > where you have enough quoted context to remember what the discussion
> is
> > > about but not too much?
> > >
> > > For me, the answer is the second, and since I prefer this for myself
> >
> > Totally agree.
> >
> > > I have toe
> > > courtesy to do the same for the mails I send, even if it takes a few
> more
> > > keystrokes. A lot of people do not bother,
> >
> > Yes, that made me wonder whether shortening would be against any rule or
> > guideline.
> >
> > One of the most annoying things with that mailing-list-style development
> > is the requirement to scroll through every single message of concern
> > while trying to spot all lines that do not have a '> ' prefix. As some
> do not
> > even put a blank line before and after a comment, you cannot rely on
> that,
> > meaning that you have to look very carefully while scrolling.
> 
> if your MUA doesnt color the text to make it easy,
> maybe you should consider a different MUA
> for example mutt can color code text based on how many ">" are there at
> the begin
> in fact mutt lets you write your own rules for how to color the mails
> I would assume any half decent MUA should be able to do something similar

Thanks a lot for your suggestion. I have no doubt that for that specific 
task a different mail client would be better than Outlook. But it would 
fail to fulfill many of the other requirements that I have, including 
extensions that I've developed that allow me to integrate my e-mail 
processing with other programs and automate certain tasks.

Kind regards,
softworkz
Soft Works Aug. 10, 2021, 2:32 p.m. UTC | #10
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Nicolas
> George
> Sent: Tuesday, 10 August 2021 16:28
> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] Mail quoting (was: libavutil/log: Add
> capability to prefix loglines with current time or current date+time)
> 
> Michael Niedermayer (12021-08-10):
> > if your MUA doesnt color the text to make it easy,
> > maybe you should consider a different MUA
> 
> This is good advice in this specific instance, but I would not consider
> it an excuse for myself not to properly trim the replies I make, on the
> principle that I should not demand many people to change their habits
> just to accommodate mine.
> 
> A little effort by one person is better than a tiny effort by many.
> 
> > for example mutt can color code text based on how many ">" are there at
> the begin
> > in fact mutt lets you write your own rules for how to color the mails
> > I would assume any half decent MUA should be able to do something
> similar
> 
> Mutt also has a short-cut (S by default) to skip until the first line of
> non-quoted text. It is a life-saver when you all do not trim your mails.

I knew you must have some "tricks" in place :-)

softworkz
Mapul Bhola Aug. 11, 2021, 1:02 p.m. UTC | #11
E.email comes with this capability built in.

August 10, 2021 10:02 AM, "Michael Niedermayer" <michael@niedermayer.cc> wrote:

> On Tue, Aug 10, 2021 at 09:47:31AM +0000, Soft Works wrote:
> 
>> -----Original Message-----
>> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
>> Nicolas George
>> Sent: Tuesday, 10 August 2021 11:16
>> To: FFmpeg development discussions and patches <ffmpeg-
>> devel@ffmpeg.org>
>> Subject: [FFmpeg-devel] Mail quoting (was: 1/2] libavutil/log: Add capability
>> to prefix loglines with current time or current date+time)
>> 
>> Soft Works (12021-08-10):
>>> I meant the e-mail body of the previous conversation.
>> 
>> Well, it is my mail, I put what I want in it, and you do what you want with
>> yours.
>> 
>> But ask yourself: which one do you find easier to read: one where you have
>> to scroll half a dozen pages of old mail just to get to the new bits, or one
>> where you have enough quoted context to remember what the discussion is
>> about but not too much?
>> 
>> For me, the answer is the second, and since I prefer this for myself
>> 
>> Totally agree.
>> 
>> I have toe
>> courtesy to do the same for the mails I send, even if it takes a few more
>> keystrokes. A lot of people do not bother,
>> 
>> Yes, that made me wonder whether shortening would be against any rule or
>> guideline.
>> 
>> One of the most annoying things with that mailing-list-style development
>> is the requirement to scroll through every single message of concern
>> while trying to spot all lines that do not have a '> ' prefix. As some do not
>> even put a blank line before and after a comment, you cannot rely on that,
>> meaning that you have to look very carefully while scrolling.
> 
> if your MUA doesnt color the text to make it easy,
> maybe you should consider a different MUA
> for example mutt can color code text based on how many ">" are there at the begin
> in fact mutt lets you write your own rules for how to color the mails
> I would assume any half decent MUA should be able to do something similar
> 
> Thanks
> 
> [...]
> 
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> Awnsering whenever a program halts or runs forever is
> On a turing machine, in general impossible (turings halting problem).
> On any real computer, always possible as a real computer has a finite number
> of states N, and will either halt in less than N cycles or never halt.
> 
> _______________________________________________
> 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".
diff mbox series

Patch

diff --git a/doc/APIchanges b/doc/APIchanges
index 6eefc7fc33..be707314f3 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -14,6 +14,9 @@  libavutil:     2021-04-27
 
 API changes, most recent first:
 
+2021-08-09 - xxxxxxxxxx - lavu 57.4.100 - log.h
+  Add new defines: AV_LOG_PRINT_TIME and AV_LOG_PRINT_DATETIME
+
 2021-08-02 - xxxxxxxxxx - lavc 59.4.100 - packet.h
   Add AVPacket.opaque, AVPacket.opaque_ref, AVPacket.time_base.
 
diff --git a/libavutil/log.c b/libavutil/log.c
index 66defa9c42..f29533a91f 100644
--- a/libavutil/log.c
+++ b/libavutil/log.c
@@ -40,6 +40,8 @@ 
 #include "internal.h"
 #include "log.h"
 #include "thread.h"
+#include "time.h"
+#include "time_internal.h"
 
 static AVMutex mutex = AV_MUTEX_INITIALIZER;
 
@@ -289,14 +291,32 @@  static const char *get_level_str(int level)
     }
 }
 
+static void format_date_now(AVBPrint* timeBuf, int include_date)
+{
+    struct tm *ptm, tmbuf;
+    int64_t time_us = av_gettime();
+    int64_t time_ms = time_us / 1000;
+    const time_t time_s = time_ms / 1000;
+    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) {
@@ -314,6 +334,10 @@  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) || (flags & 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));
 
@@ -334,7 +358,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);
@@ -348,7 +372,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];
@@ -383,6 +407,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 8727c38afc..27eb071884 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 6b4a265457..201b012596 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@ 
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  57
-#define LIBAVUTIL_VERSION_MINOR   3
+#define LIBAVUTIL_VERSION_MINOR   4
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \