Module: R7Insight
- Defined in:
- lib/r7_insight.rb,
lib/r7_insight/host.rb,
lib/r7_insight/host/connection.rb
Overview
Rapid7 Insight Platform Ruby Logging functionality
Defined Under Namespace
Modules: Host
Class Method Summary collapse
- .check_params(token, region, opt_datahub_enabled, opt_udp_port) ⇒ Object
- .new(token, region, options = {}) ⇒ Object
Class Method Details
.check_params(token, region, opt_datahub_enabled, opt_udp_port) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/r7_insight.rb', line 45 def self.check_params(token, region, opt_datahub_enabled, opt_udp_port) # test Token only when DataHub and UDP are not enabled return unless !opt_datahub_enabled && !opt_udp_port # Check if the key is valid UUID format if (token =~ /\A(urn:uuid:)?[\da-f]{8}-([\da-f]{4}-){3}[\da-f]{12}\z/i).nil? puts "\nLE: It appears the R7INSIGHT_TOKEN you entered is invalid!\n" end puts "\nLE: You need to specify region, such as 'eu'" unless region end |
.new(token, region, options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/r7_insight.rb', line 9 def self.new(token, region, = {}) opt_local = [:local] || false opt_debug = [:debug] || false opt_ssl = !.include?(:ssl) ? true : [:ssl] opt_tag = [:tag] || false opt_log_level = [:log_level] || Logger::DEBUG opt_datahub_enabled = [:datahub_enabled] || false opt_datahub_endpoint = [:datahub_endpoint] || ['', 10_000] opt_host_id = [:host_id] || '' opt_custom_host = [:custom_host] || [false, ''] opt_udp_port = [:udp_port] || nil opt_use_data_endpoint = [:data_endpoint] || false check_params(token, region, opt_datahub_enabled, opt_udp_port) host = R7Insight::Host.new(token, region, opt_local, opt_debug, opt_ssl, opt_datahub_endpoint, opt_host_id, opt_custom_host, opt_udp_port, opt_use_data_endpoint) if defined?(ActiveSupport::TaggedLogging) && opt_tag logger = ActiveSupport::TaggedLogging.new(Logger.new(host)) elsif defined?(ActiveSupport::Logger) logger = ActiveSupport::Logger.new(host) logger.formatter = host.formatter if host.respond_to?(:formatter) else logger = Logger.new(host) logger.formatter = host.formatter if host.respond_to?(:formatter) end logger.level = opt_log_level logger end |