Skip to content

Commit

Permalink
Redirect logs into log/nuage.log file
Browse files Browse the repository at this point in the history
With this commit we redirect all Nuage specific logs
into a dedicated file (instead of general-purpose evm.log).

Signed-off-by: Miha Pleško <miha.plesko@xlab.si>
  • Loading branch information
miha-plesko committed Feb 12, 2018
1 parent c90e1ff commit e170dbc
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 14 deletions.
6 changes: 4 additions & 2 deletions .rubocop_local.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# GlobalVars:
# AllowedVariables:
GlobalVars:
AllowedVariables:
# Loggers
- $nuage_log
6 changes: 3 additions & 3 deletions app/models/manageiq/providers/nuage/manager_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def raw_connect(username, password, endpoint_opts)
api_version = endpoint_opts[:api_version] ? endpoint_opts[:api_version].strip : 'v5_0'

url = auth_url(protocol, hostname, api_port, api_version)
_log.info("Connecting to Nuage VSD with url #{url}")
$nuage_log.info("Connecting to Nuage VSD with url #{url}")

connection_rescue_block do
ManageIQ::Providers::Nuage::NetworkManager::VsdClient.new(url, username, password)
Expand Down Expand Up @@ -47,7 +47,7 @@ def connection_rescue_block
rescue => err
miq_exception = translate_exception(err)

_log.error("Error Class=#{err.class.name}, Message=#{err.message}")
$nuage_log.error("Error Class=#{err.class.name}, Message=#{err.message}")
raise miq_exception
end
end
Expand Down Expand Up @@ -114,7 +114,7 @@ def verify_amqp_credentials(_options = {})

def stop_event_monitor_queue_on_change
if event_monitor_class && !new_record? && (authentications.detect(&:changed?) || endpoints.detect(&:changed?))
_log.info("EMS: [#{name}], Credentials or endpoints have changed, stopping Event Monitor. It will be restarted by the WorkerMonitor.")
$nuage_log.info("EMS: [#{name}], Credentials or endpoints have changed, stopping Event Monitor. It will be restarted by the WorkerMonitor.")
stop_event_monitor_queue
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def initialize(options = {})
end

def start(&message_handler_block)
_log.debug("#{self.class.log_prefix} Opening amqp connection using options #{@options}")
$nuage_log.debug("#{self.class.log_prefix} Opening amqp connection using options #{@options}")
@options[:message_handler_block] = message_handler_block if message_handler_block
with_fallback_urls(@options[:urls]) do
connection.run
Expand All @@ -49,12 +49,12 @@ def connection
def with_fallback_urls(urls)
urls.each_with_index do |url, idx|
endpoint_str = "ActiveMQ endpoint #{idx + 1}/#{@options[:urls].count} (#{url})"
_log.info("#{self.class.log_prefix} Connecting to #{endpoint_str}")
$nuage_log.info("#{self.class.log_prefix} Connecting to #{endpoint_str}")
begin
@options[:url] = url
yield
rescue MiqException::MiqHostError, Errno::ECONNREFUSED, SocketError => err
_log.info("#{self.class.log_prefix} #{endpoint_str} errored: #{err}")
$nuage_log.info("#{self.class.log_prefix} #{endpoint_str} errored: #{err}")
stop
reset_connection
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ def initialize(ems, options = nil)
def ems_inv_to_hashes
log_header = "MIQ(#{self.class.name}.#{__method__}) Collecting data for EMS name: [#{@ems.name}] id: [#{@ems.id}]"

_log.info("#{log_header}...")
$nuage_log.info("#{log_header}...")
get_enterprises
get_policy_groups
_log.info(@data)
$nuage_log.info(@data)
@data
end

Expand Down Expand Up @@ -119,7 +119,7 @@ def map_extra_attributes(subnet_parent_id)

def parse_policy_group(pg)
uid = pg['ID']
_log.info(@domains[pg['parentID']][2])
$nuage_log.info(@domains[pg['parentID']][2])
new_result = {
:type => self.class.security_group_type,
:ems_ref => uid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def initialize(server, user, password)
@enterprise_id = data
return
end
_log.error('VSD Authentication failed')
$nuage_log.error('VSD Authentication failed')
end

def get_enterprises
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def get(url)
if @api_key == ''
login
end
_log.debug("GET for Nuage VSD url #{url}")
$nuage_log.debug("GET for Nuage VSD url #{url}")
RestClient::Request.execute(:method => :get, :url => url, :user => @user, :password => @api_key,
:headers => @headers, :verify_ssl => false) do |response|
return response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
it "preserves and logs message for unknown exceptions" do
allow(@ems).to receive(:with_provider_connection).and_raise(StandardError, "unlikely")

expect($log).to receive(:error).with(/unlikely/)
expect($nuage_log).to receive(:error).with(/unlikely/)
expect { @ems.verify_credentials }.to raise_error(MiqException::MiqEVMLoginError, /Unexpected.*unlikely/)
end

Expand Down

0 comments on commit e170dbc

Please sign in to comment.