How to Suppress Printk()

In my program, I want to supress all the Printk() statements conditionaly either from prj.conf or CMakeLists etc ? Or in simple terms, want to supress UART0 consol when required. What statements in prj.conf or CMakeLists or Board.dts etc need to be added/ removed ? The printk() messages sent to the consol are shown in the attched image file. UART0 is used by default to send  messages o consol. In my project, I need to  interface a serial device othe than consol. SO, these unwante messages are not required during normal run of application. Printk messages are  required initilly for verification of aloocation and initialization  of SOC resources. So, guide how to conditionaly include/ discard such messages ? To type #ifdef #endif block every where is a tediuos task. As well, before reaching to main() function in the application, the kernel sends some default messages to consol. The #ifdef #endif block may easily be inserted in the application code only not in the kernel initialization code by the developer.

Related