Made log method thread safe
Implemented query listener.