Added debug logging capabilities (enable them with $api->debug()).