Recommended ways to log driver operations

M. Warner Losh imp at bsdimp.com
Mon Oct 17 20:09:36 PDT 2005


In message: <67beabb0510171825q1e124bf6v2adbe0c9f235a6ae at mail.gmail.com>
            Bharma Ji <bharmaji at gmail.com> writes:
: I recently wrote a driver for a chip. I am wondering if there are any
: standard recommended ways of logging the driver operations. I have used
: printf in the driver and I look at it using dmesg so far. Am wondering if it
: is possible to create a driver specific log file so that it is easy to
: debug. Also, if the driver emits copious output then the log buffer will
: overflow and some messages may be truncated. Writing to a specific log file
: may help in that case. However, I have no idea if this is worth
: investigating. Any suggestions appreciated

printf(9) doesn't give you much of a chance to segregate the logs.  You
can also use log(9), but that just adds the ability to give a priority
to the log message, which can help.

If you want to debug the driver to find out what's going on at a high
rate, you might want to look at ktr(9) and alq(9).  These facilities
are more for debugging and performance tuning, rather than day to day
operations.  In general, FreeBSD drivers follow the unix tradition of
only complaining when there are problems.

Warner


More information about the freebsd-drivers mailing list