Output format under Linux

The printk function can specify the priority of the output:
  KERN_EMERG"<0>"/*Emergency event message, prompt before the system crashes, indicating that the system is unavailable*/
  KERN_ALERT"<1>"/*Report message indicating that immediate action must be taken*/
  KERN_CRIT"<2>"/*critical condition, usually involving severe hardware or software operation failure*/
  KERN_ERR"<3>"/*Error conditions, drivers often use KERN_ERR to report hardware errors*/
  KERN_WARNING"<4>"/*Warning condition, warn about possible problems */
  KERN_NOTICE"<5>"/*Normal but important condition for reminder. Often used for security related messages */
  KERN_INFO"<6>"/*Prompt information, such as when the driver starts, print hardware information*/
  KERN_DEBUG"<7>"/*Debug level messages*/
  If the variable type is, use prink's format specifier:
  int %d or %x (note: %d is decimal, %x is hexadecimal)
  unsigned int %u or %x
  long %ld or %lx
  unsigned long %lu or %lx
  long long %lld or %llx
  unsigned long long %llu or %llx
   size_t  %zu or %zx
  ssize_t %zd or %zx
  Raw pointer values ​​must be output with %p.
  u64, ie (unsigned long logn), must be output with %llu or %llx, such as:
  printk("%llu", (unsigned long long)u64_var);
  s64, i.e. (long long), must be output with %lld or %llx, such as:
  printk("%lld", (long long)s64_var);
  If the length of (variable type) <type> depends on a configuration option (eg: sector_t, blkcnt_t, phys_addr_t, resource_size_t) or on the relevant architecture (eg: tcflag_t ), use a format specifier of the largest possible type, and display the conversion it. Such as:

  printk("test: sector number/total blocks: %llu/%llu\n",(unsigned long long)sector, (unsigned long long)blockcount);



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326223874&siteId=291194637