I believe there is already debugging and logging support on device driver side.
As a startpoint you should investigate the driver in the linux kernel which starts here:
https://github.com/torvalds/linux/blob/master/drivers/scsi/scsi_module.c
And for the debugging you find this one:
https://github.com/torvalds/linux/blob/master/drivers/scsi/scsi_logging.c
And it is always a good idea to read the manual first! Give it a chance here:
https://www.kernel.org/doc/Documentation/scsi/
If you can't get logging activated, you should come back and ask a more specific question. But I believe you have no need to write your own logger at all.
From http://www.theunixway.com/2013/10/ol56-enable-additional-scsi-logging-or.html
Enabling scsi logging on kernel:
sysctl -q -w dev.scsi.logging_level=<N>
or
echo <N> > /proc/dev/scsi/logging_level
N is a bit field which contains different categories of logging information. Please refer to the documentation of the actual kernel driver version you use.