Add query logging.

Three new options added
- log_queries, if true log queries, defaults to false
- log_queries_filename, the file where queries are logged, defaults to `queries.log`
- log_queries_threshold, only log queries that run slower than threshold (in milliseconds)
  defaults to 0, i.e. log all queries.
It seems a bit sad that the interface for this doesn't define any methods.

Looking at the implementations of this interface, they are more or less lazy strings, so all the smarts of an implementation of this interface is "supposed to" happen in to `toString()` method. How about at least adding `toString()` in the declaration of this interface, along with a javadoc string that details how it is used, and what it should provide. This will greatly help in implementing this interface.