printk or pr_<level>?

Kristofer Hallin kristofer.hallin at gmail.com
Wed Jul 23 14:40:04 EDT 2014


Yes.

https://www.kernel.org/doc/local/pr_debug.txt

On Wed, Jul 23, 2014 at 8:39 PM, Fernando Apesteguía
<fernando.apesteguia at gmail.com> wrote:
>
>
>
> On Wed, Jul 23, 2014 at 8:34 PM, Kristofer Hallin
> <kristofer.hallin at gmail.com> wrote:
>>
>> 1. No. Depending on what subsystem your are printing logs from you
>> should use different functions for logging. In the networking
>> subsystem netdev_dbg is suitable and so on. Otherwise pr_debug will
>> always work and is always preferred over printk.
>
>
> By default, pr_debug is an empty macro unless you add -DDEBUG to CFLAGS. So
> in addition to what Kristofer said, be sure you compile your module/kernel
> with that flag enabled.
>
> Cheers.
>
>>
>>
>> 2. Use pr_debug.
>>
>> On Wed, Jul 23, 2014 at 8:16 PM, Raphael Silva
>> <raphaelcampos.rp at gmail.com> wrote:
>> > Hello guys,
>> >
>> > 1)
>> > If I use printk(KERN_<LEVEL>...) the checkpatch warns me:
>> > WARNING: Prefer [subsystem eg: netdev]_dbg([subsystem]dev, ... then
>> > dev_dbg(dev, ... then pr_debug(...  to printk(KERN_DEBUG ...
>> >
>> > So, pr_devel() is the correct way to print a debug level msg?
>> >
>> > 2)
>> > if pr_<level> is the correct way, what about KERN_DEFAULT ?
>> >
>> > If I don't put the kern_level (printk("Hello");)
>> > WARNING: printk() should include KERN_ facility level
>> >
>> > if I put KERN_DEFAULT:
>> > WARNING: Prefer [subsystem eg: netdev]_default([subsystem]dev, ... then
>> > dev_default(dev, ... then pr_default(...  to printk(KERN_DEFAULT ...
>> >
>> > But for KERN_DEFAULT, there isn't a macro pr_<level> like pr_devel().
>> >
>> > Can anyone show me the correct way?
>> >
>> > tks
>> >
>> >
>> >
>> >
>> > _______________________________________________
>> > Kernelnewbies mailing list
>> > Kernelnewbies at kernelnewbies.org
>> > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>>
>> _______________________________________________
>> Kernelnewbies mailing list
>> Kernelnewbies at kernelnewbies.org
>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>



More information about the Kernelnewbies mailing list