Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed logging for proxy when storage not defined #15028

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion app/models/vm_or_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,14 @@ def log_all_proxies(all_proxy_list, message)
end

def log_proxies_vm_config
"[#{log_proxies_format_instance(self)}] on host [#{log_proxies_format_instance(host)}] #{ui_lookup(:table => "storages").downcase} [#{storage.name}-#{storage.store_type}]"
msg = "[#{log_proxies_format_instance(self)}] on host [#{log_proxies_format_instance(host)}] "\
"#{ui_lookup(:table => "storages").downcase} "
msg += if storage
"[#{storage.name}-#{storage.store_type}]"
else
"No storage"
end
msg
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style:

  • Avoid the line continuation \...just make it a single line.
  • Prefer << over +=
  • There's no need to append and then return the variable, it can be done in one shot
  def log_proxies_vm_config
    msg = "[#{log_proxies_format_instance(self)}] on host [#{log_proxies_format_instance(host)}] #{ui_lookup(:table => "storages").downcase} "
    msg << storage ? "[#{storage.name}-#{storage.store_type}]" : "No storage"
  end

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Fryguy OK, it does look cleaner, will change it in PR removing not used log_proxies

end

def log_proxies_format_instance(object)
Expand Down