I realize this isn't your question, but you might consider using a tool like netcat instead of messing with the code (which doesn't seem like a trivial change).
You can do something like this (updated to use a log fifo):
mkfifo /path/to/log
nc < /path/to/log
http://netcat.sourceforge.net/