lib/bmc-daemon-lib/conf.rb in bmc-daemon-lib-0.3.8 vs lib/bmc-daemon-lib/conf.rb in bmc-daemon-lib-0.3.10
- old
+ new
@@ -89,11 +89,10 @@
fail ConfigParseError, e.message
rescue StandardError => e
fail ConfigOtherError, "#{e.message} \n #{e.backtrace.to_yaml}"
end
-
# Reload files
def self.reload!
ensure_init
load_files
end
@@ -131,13 +130,17 @@
# Guess if the specific feature si available
case name
when :newrelic
return false if Gem.datadir('newrelic_rpm').nil?
+ return if self.at(:newrelic, :enabled) == false
+ return if self.at(:newrelic, :disabled) == true
return self.at(:newrelic, :license)
when :rollbar
return false if Gem.datadir('rollbar').nil?
+ return if self.at(:rollbar, :enabled) == false
+ return if self.at(:rollbar, :disabled) == true
return self.at(:rollbar, :token)
end
return false
end
@@ -200,11 +203,17 @@
ENV["NEWRELIC_AGENT_ENABLED"] = "true"
end
def self.prepare_rollbar
# Disable if no config present
- return unless self.feature?(:rollbar)
+ unless self.feature?(:rollbar)
+ Rollbar.configure do |config|
+ config.enabled = false
+ end
+ return
+ end
+
section = self[:rollbar]
# Configure
Rollbar.configure do |config|
config.enabled = true
@@ -216,9 +225,18 @@
config.use_async = true
end
# Notify startup
Rollbar.info("#{@app_name} #{@app_ver} [#{@host}]")
+ end
+
+ def self.log origin, message
+ printf(
+ "%s %-10s %s \n",
+ Time.now.strftime("%Y-%m-%d %H:%M:%S"),
+ origin,
+ message
+ )
end
protected
def self.load_files