Adding logging

Mostly stolen from
http://dev.splunk.com/view/splunk-extensions/SP-CAAAEA9