Implemented logging

Messages are not printed to log files
and the way data is passed to the
database API has be corrected.