<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Logging function without runtime filtering but includes timestamp and end of line termination</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/113867/logging-function-without-runtime-filtering-but-includes-timestamp-and-end-of-line-termination</link><description>Using Zephyr. 
 I&amp;#39;m looking for a process or a function to log unconditional message in the logging system including timestamp and other typical logging/display functionality. LOG_RAW strips time stamps and EOL termination. LOG_INF -&amp;gt; LOG_ERR are all</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 13 Aug 2024 19:01:54 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/113867/logging-function-without-runtime-filtering-but-includes-timestamp-and-end-of-line-termination" /><item><title>RE: Logging function without runtime filtering but includes timestamp and end of line termination</title><link>https://devzone.nordicsemi.com/thread/498129?ContentTypeID=1</link><pubDate>Tue, 13 Aug 2024 19:01:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8fce105c-d5ee-481a-932e-43ca078748b7</guid><dc:creator>GabrielDS</dc:creator><description>&lt;p&gt;I&amp;#39;m sorry, these instructions are not specific enough or I&amp;#39;m not understanding.&amp;nbsp;&amp;nbsp;&lt;a href="https://docs.zephyrproject.org/apidoc/latest/group__log__ctrl.html#gaea92150610f900ab1258cbce65662ae6"&gt;log_set_timestamp_func&lt;/a&gt;&amp;nbsp;doesn&amp;#39;t return a timestamp, only configures how the timestamping works, only though the typical LOG_XXX functions.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Are you ultimately suggesting to just build a string in userspace and just pass that on to LOG_PRINTK?&lt;/p&gt;
&lt;p&gt;What I&amp;#39;d really like to see is a way to use something like&amp;nbsp;&lt;span class="sig-name descname"&gt;&lt;span class="n"&gt;&lt;span class="pre"&gt;LOG_MSG_SIMPLE_FUNC&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="sig-paren"&gt;(&lt;/span&gt;&lt;span class="n"&gt;&lt;span class="pre"&gt;_source&lt;/span&gt;&lt;/span&gt;&lt;span&gt;,&amp;nbsp;&lt;/span&gt;&lt;span class="n"&gt;&lt;span class="pre"&gt;_level&lt;/span&gt;&lt;/span&gt;&lt;span&gt;,&amp;nbsp;&lt;/span&gt;&lt;span class="p"&gt;&lt;span class="pre"&gt;...&lt;/span&gt;&lt;/span&gt;&lt;span class="sig-paren"&gt;) with a custom _source or some other lower level function to bypass the filtering capabilities but retain the already built in timestamping.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Logging function without runtime filtering but includes timestamp and end of line termination</title><link>https://devzone.nordicsemi.com/thread/497947?ContentTypeID=1</link><pubDate>Tue, 13 Aug 2024 07:51:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f8f2a1f7-0101-45ec-ab2e-831598fc7a52</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;div&gt;&lt;span style="font-size:inherit;"&gt;Zephyr logging system does not seem to have a built-in function that meets all your requirements. However, you can use a combination of the available functions and features to achieve your goal.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-size:inherit;"&gt;The &lt;a href="https://docs.nordicsemi.com/bundle/ncs-1.9.2-dev1/page/kconfig/CONFIG_LOG_PRINTK.html"&gt;LOG_PRINTK&lt;/a&gt;&lt;code dir="ltr"&gt;()&lt;/code&gt;&amp;nbsp;function is the closest to what you&amp;#39;re looking for. It unconditionally prints raw log messages, similar to the&amp;nbsp;&lt;code dir="ltr"&gt;printk()&lt;/code&gt;&amp;nbsp;function, but it goes through the logging infrastructure, thus utilizing logging modes such as deferred mode. However, it does not automatically append timestamps or line terminations.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div dir="ltr"&gt;
&lt;div&gt;
&lt;div&gt;&lt;span style="font-size:inherit;"&gt;Timestamps can be added to log messages by using the&amp;nbsp;&lt;code dir="ltr"&gt;&lt;a href="https://docs.zephyrproject.org/apidoc/latest/group__log__ctrl.html#gaea92150610f900ab1258cbce65662ae6"&gt;log_set_timestamp_func&lt;/a&gt;()&lt;/code&gt;&amp;nbsp;function. This function allows you to set a custom function that returns the timestamp value. If not provided,&amp;nbsp;&lt;code dir="ltr"&gt;k_cycle_get&lt;/code&gt;&amp;nbsp;or&amp;nbsp;&lt;code dir="ltr"&gt;k_cycle_get_32&lt;/code&gt;&amp;nbsp;is used for timestamping.&lt;/span&gt;
&lt;div&gt;&lt;span style="font-size:inherit;"&gt;Here is an example of how you can use it:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div dir="ltr"&gt;
&lt;div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&lt;span style="font-size:inherit;"&gt;In this example,&amp;nbsp;&lt;code dir="ltr"&gt;custom_timestamp_func&lt;/code&gt;&amp;nbsp;is your custom function that returns the timestamp, and&amp;nbsp;&lt;code dir="ltr"&gt;timestamp_freq&lt;/code&gt;&amp;nbsp;is the frequency of your timestamp source.you can use the &lt;a href="https://docs.zephyrproject.org/apidoc/latest/group__log__output.html#ga4e69b802ec5caef8178b0de88fc68412"&gt;log_output_timestamp_freq_set&lt;/a&gt;&lt;code dir="ltr"&gt;()&lt;/code&gt;&amp;nbsp;function, which sets the frequency of the timestamp. H&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div dir="ltr"&gt;
&lt;div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>