Added Debug mode for console logging.
Results are onlyr eturned in JSON , no log messages when debug = false, this enables php script to consume json results.