Add setTraceFunction() method to query

This allows the developer to track when a query starts and ends
for logging/timing/debugging purposes. There is also a global
Query.setGlobalTraceFunction() that applies the trace function
to all queries.

The trace function is passed information about the query, and is
expected to return a function that will be called with information
about the result.
Merge pull request #53 from jlai/trace-function

Add setTraceFunction() method to query