Sometimes it is easier to have our own identifier in print messages to easily filter/grep messages from the dmesg. It is also useful when we want to have some fixed data (e.g. __func__ or __LINE__). This also helps in debugging.
We can format pr_messages by defining pr_fmt macro.
#define pr_fmt "<custom-fmt>" fmt, <custom-param-for-custom-fmt>
e.g. you can print kernel module name using below:
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
I generally define it like below format for my debug messages. It prints out “rmv” and function name before any pr_* messages.
#define pr_fmt " rmv: %s() %d " fmt, __func__, __LINE__
Below is print statement at line 25 in my_func()
Its output would like below after timestamp:
rmv: my_func() 25 Hello World