tests: Add test for the logging function.
log: Add check for return value.

For some reason I got a segfault in gdb here. Make sure it works
correctly.