Remove trailing whitespaces
Fix variable scope
Add proper logging

Note: log level can be set using VCLOUD_REST_DEBUG_LEVEL and log's
output can be set using VCLOUD_REST_LOG_FILE