lib: Expose query debug output via an environment variable