Removed print_r and added array check to variables passed to logError