log timestamp formatting


Gordon Klaus <gordon@...>
 

Hello!

 

Is it really necessary to implement an entire logging backend just to achieve custom timestamp formatting?

I was hopeful when I came across CONFIG_LOG_BACKEND_FORMAT_TIMESTAMP.  But this is just a boolean, not a format string.

I want my log messages to be prefixed with date and time.  Now I wonder, is it a bad idea?  Why else would such functionality be missing?

 

Cheers,

Gordon


Chruściński, Krzysztof
 

Hi,

 

Log_output module has timestamp formatting functionality. It is a helper module that is used by most of the backends. Processing function accepts flags and one is LOG_OUTPUT_FLAG_FORMAT_TIMESTAMP. If you want different formatting then you can try to extend log_output or implement it directly in your own backend.

 

Regards,

Krzysztof

 

From: users@... <users@...> On Behalf Of Gordon Klaus via lists.zephyrproject.org
Sent: Friday, July 1, 2022 4:08 PM
To: users@...
Subject: [Zephyr-users] log timestamp formatting

 

Hello!

 

Is it really necessary to implement an entire logging backend just to achieve custom timestamp formatting?

I was hopeful when I came across CONFIG_LOG_BACKEND_FORMAT_TIMESTAMP.  But this is just a boolean, not a format string.

I want my log messages to be prefixed with date and time.  Now I wonder, is it a bad idea?  Why else would such functionality be missing?

 

Cheers,

Gordon


Gordon Klaus <gordon@...>
 

Thanks for your reply.  I guess what you are saying is: yes, I must implement my own backend?
Is there an example of a minimal backend?  The ones I saw seemed quite involved.


From: Chruściński, Krzysztof <Krzysztof.Chruscinski@...>
Sent: Friday, July 1, 2022 4:14:40 PM
To: Gordon Klaus <gordon@...>; users@... <users@...>
Subject: RE: log timestamp formatting
 

Hi,

 

Log_output module has timestamp formatting functionality. It is a helper module that is used by most of the backends. Processing function accepts flags and one is LOG_OUTPUT_FLAG_FORMAT_TIMESTAMP. If you want different formatting then you can try to extend log_output or implement it directly in your own backend.

 

Regards,

Krzysztof

 

From: users@... <users@...> On Behalf Of Gordon Klaus via lists.zephyrproject.org
Sent: Friday, July 1, 2022 4:08 PM
To: users@...
Subject: [Zephyr-users] log timestamp formatting

 

Hello!

 

Is it really necessary to implement an entire logging backend just to achieve custom timestamp formatting?

I was hopeful when I came across CONFIG_LOG_BACKEND_FORMAT_TIMESTAMP.  But this is just a boolean, not a format string.

I want my log messages to be prefixed with date and time.  Now I wonder, is it a bad idea?  Why else would such functionality be missing?

 

Cheers,

Gordon


Carles Cufi
 

I don’t think you need to create your own backend if you are willing to send a PR or carry an out-of-tree patch. As long as your backed of choice is using log_output_msg_process():

 

From what I can tell you would need to modify timestamp_print() in log_output.c. You could propose a patch to reformat the timestamp based on Kconfig options.

If you don’t want to send a patch upstream you can probably just modify that function yourself locally.

 

Carles

 

From: users@... <users@...> On Behalf Of Gordon Klaus via lists.zephyrproject.org
Sent: 01 July 2022 16:50
To: Chruściński, Krzysztof <Krzysztof.Chruscinski@...>; users@...
Subject: Re: [Zephyr-users] log timestamp formatting

 

Thanks for your reply.  I guess what you are saying is: yes, I must implement my own backend?

Is there an example of a minimal backend?  The ones I saw seemed quite involved.


From: Chruściński, Krzysztof <Krzysztof.Chruscinski@...>
Sent: Friday, July 1, 2022 4:14:40 PM
To: Gordon Klaus <gordon@...>; users@... <users@...>
Subject: RE: log timestamp formatting

 

Hi,

 

Log_output module has timestamp formatting functionality. It is a helper module that is used by most of the backends. Processing function accepts flags and one is LOG_OUTPUT_FLAG_FORMAT_TIMESTAMP. If you want different formatting then you can try to extend log_output or implement it directly in your own backend.

 

Regards,

Krzysztof

 

From: users@... <users@...> On Behalf Of Gordon Klaus via lists.zephyrproject.org
Sent: Friday, July 1, 2022 4:08 PM
To: users@...
Subject: [Zephyr-users] log timestamp formatting

 

Hello!

 

Is it really necessary to implement an entire logging backend just to achieve custom timestamp formatting?

I was hopeful when I came across CONFIG_LOG_BACKEND_FORMAT_TIMESTAMP.  But this is just a boolean, not a format string.

I want my log messages to be prefixed with date and time.  Now I wonder, is it a bad idea?  Why else would such functionality be missing?

 

Cheers,

Gordon