How to block Logd\logi and other printouts

Source: Internet
Author: User

Today is the removal of printed information troubled, think, if a change by one is too cumbersome. So look carefully at this part of the printing principle. Of course, the following is simply a list of knowledge, but the need for friends can casually look. There is no doubt that there will be some gains.

The include/linux/printk.h is defined as follows:

#defineKERN_EMERG

"<0>"

/* System is unusable

*/

#defineKERN_ALERT

"<1>"

/* Action must be taken immediately

*/

#defineKERN_CRIT

"<2>"

/* Critical conditions

*/

#defineKERN_ERR

"<3>"

/* ERROR conditions

*/

#defineKERN_WARNING

"<4>"

/* Warning conditions

*/

#defineKERN_NOTICE

"<5>"

/* Normal but significant condition

*/

#defineKERN_INFO

"<6>"

/* Informational

*/

#defineKERN_DEBUG

"<7>"

/* Debug-level messages

*/

/*use the default kernel loglevel */

#defineKERN_DEFAULT

"<d>"

/*

*annotation for a "continued" line of log printout

*line that had no enclosing \ n). Used by Core/arch code

*during Early bootup (a continued line was not smp-safe otherwise).

*/

#defineKERN_CONT

"<c>"

Externint console_printk[];

#defineconsole_loglevel (Console_printk[0])

#definedefault_message_loglevel (Console_printk[1])

#defineminimum_console_loglevel (Console_printk[2])

#definedefault_console_loglevel (Console_printk[3])

This defines the parameters that are normally used when the Prink function is called. The above definition provides a clear view of the system's default loglevel, including the logging level and console level.

/*PRINTK ' s without a loglevel use this: */

#defineDEFAULT_MESSAGE_LOGLEVEL Config_default_message_loglevel

/*we show everything that's more important than this: */

#defineMINIMUM_CONSOLE_LOGLEVEL 1/* Minimum LOGLEVEL We let people use */

#defineDEFAULT_CONSOLE_LOGLEVEL 7/* Anything more serious than kern_debug */

Declare_wait_queue_head (log_wait);

Intconsole_printk[4] = {

Default_console_loglevel,

/* Console_loglevel */

Default_message_loglevel,

/* Default_message_loglevel */

Minimum_console_loglevel,

/* Minimum_console_loglevel */

Default_console_loglevel,

/* Default_console_loglevel */

};

From the above, you can know that when the Linux kernel starts, you can see the log information of those levels. Of course, in many cases, the addition of printing information is to facilitate debugging, when the system starts, it is likely that we become very annoying to add the log information, or want to see a level of information. It would be a waste of time if you recompile kernel and then burn the writing. In this case, it should be better to change the log level in a timely manner to see the log information you really want to see.

Since there is such a demand, can Linux provide it?

The answer is certainly not surprising, in the special file proc in Linux, there are files that can be manipulated.

Use the following command to view the current PRINTK situation:

#cat/PROC/SYS/KERNEL/PRINTK

7 4 1 7

In contrast to the above information, you know that the level in the console is now 7, in order to block some information, you can use the following command

#echo 4 >/PROC/SYS/KERNEL/PRINTK

Macro definitions such as Loge\logd\logi are generally used in a company's own internal definition of the printing function, generally defined in a log-private.h file on the board side, after being referenced by a log.h file, referenced by the hardware.h file. If the header file is included in the driver, then the LOGI Print macro definition can be used in the program.

Go to: http://blog.csdn.net/codectq/article/details/24734269

How to block Logd\logi and other printouts

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.