Class: SoarAuditingProvider::AuditingProvider
- Inherits:
-
SoarAuditingProviderAPI::AuditingProviderAPI
- Object
- SoarAuditingProviderAPI::AuditingProviderAPI
- SoarAuditingProvider::AuditingProvider
- Defined in:
- lib/soar_auditing_provider/auditing_provider.rb
Constant Summary collapse
- DEFAULT_FLOW_ID_GENERATOR =
-> { SoarFlow::ID::generate_flow_id }
- DEFAULT_LEVEL =
:info- DEFAULT_QUEUE_WORKER_CONFIG =
{ "queue_size" => 1000, "initial_back_off_in_seconds" => 1, "back_off_multiplier" => 2, "back_off_attempts" => 5 }
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#service_identifier ⇒ Object
Returns the value of attribute service_identifier.
- #startup_flow_id ⇒ Object
Instance Method Summary collapse
- #audit_exception(exception:, level: :error, flow_id: nil, message: nil) ⇒ Object
- #debug(data, flow_identifier = nil) ⇒ Object
- #detailed_status ⇒ Object
- #error(data, flow_identifier = nil) ⇒ Object
- #fatal(data, flow_identifier = nil) ⇒ Object
- #flush(timeout: 1) ⇒ Object
- #info(data, flow_identifier = nil) ⇒ Object (also: #<<)
-
#initialize(configuration) ⇒ AuditingProvider
constructor
A new instance of AuditingProvider.
- #select_auditor(nfrs) ⇒ Object
- #set_audit_level(level) ⇒ Object
- #warn(data, flow_identifier = nil) ⇒ Object
Constructor Details
#initialize(configuration) ⇒ AuditingProvider
Returns a new instance of AuditingProvider.
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/soar_auditing_provider/auditing_provider.rb', line 34 def initialize(configuration) @configuration = configuration super(create_auditors(configuration)) select_auditor(configuration['default_nfrs']) @flow_id_generator = @configuration["flow_id_generator"] || DEFAULT_FLOW_ID_GENERATOR create_auditing_worker @buffer_overflow_count = 0 install_at_exit_handler initialize_metrics end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
31 32 33 |
# File 'lib/soar_auditing_provider/auditing_provider.rb', line 31 def configuration @configuration end |
#service_identifier ⇒ Object
Returns the value of attribute service_identifier.
30 31 32 |
# File 'lib/soar_auditing_provider/auditing_provider.rb', line 30 def service_identifier @service_identifier end |
#startup_flow_id ⇒ Object
45 46 47 |
# File 'lib/soar_auditing_provider/auditing_provider.rb', line 45 def startup_flow_id @startup_flow_id ||= @flow_id_generator.call end |
Instance Method Details
#audit_exception(exception:, level: :error, flow_id: nil, message: nil) ⇒ Object
95 96 97 98 99 100 101 |
# File 'lib/soar_auditing_provider/auditing_provider.rb', line 95 def audit_exception(exception:, level: :error, flow_id: nil, message: nil) = "#{exception.class}: #{exception.}" = "#{} - #{}" if = + ":\n\t" + exception.backtrace.join("\n\t") level = :error if not is_valid_audit_level?(level) send(level,,flow_id) end |
#debug(data, flow_identifier = nil) ⇒ Object
61 62 63 |
# File 'lib/soar_auditing_provider/auditing_provider.rb', line 61 def debug(data, flow_identifier = nil) audit(:debug, data, flow_identifier) end |
#detailed_status ⇒ Object
83 84 85 86 87 |
# File 'lib/soar_auditing_provider/auditing_provider.rb', line 83 def detailed_status detail = basic_status_detail detail = detail.merge(verbose_status_detail) if @configuration['verbose_detail'] detail end |
#error(data, flow_identifier = nil) ⇒ Object
75 76 77 |
# File 'lib/soar_auditing_provider/auditing_provider.rb', line 75 def error(data, flow_identifier = nil) audit(:error, data, flow_identifier) end |
#fatal(data, flow_identifier = nil) ⇒ Object
79 80 81 |
# File 'lib/soar_auditing_provider/auditing_provider.rb', line 79 def fatal(data, flow_identifier = nil) audit(:fatal, data, flow_identifier) end |
#flush(timeout: 1) ⇒ Object
89 90 91 92 93 |
# File 'lib/soar_auditing_provider/auditing_provider.rb', line 89 def flush(timeout: 1) if @worker @worker.flush(timeout: timeout) end end |
#info(data, flow_identifier = nil) ⇒ Object Also known as: <<
65 66 67 |
# File 'lib/soar_auditing_provider/auditing_provider.rb', line 65 def info(data, flow_identifier = nil) audit(:info, data, flow_identifier) end |
#select_auditor(nfrs) ⇒ Object
49 50 51 52 |
# File 'lib/soar_auditing_provider/auditing_provider.rb', line 49 def select_auditor(nfrs) select(nfrs) set_audit_level(configured_audit_level) end |
#set_audit_level(level) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/soar_auditing_provider/auditing_provider.rb', line 54 def set_audit_level(level) @auditor.set_audit_level(level) rescue ArgumentError $stderr.puts 'Invalid auditing level' raise end |
#warn(data, flow_identifier = nil) ⇒ Object
71 72 73 |
# File 'lib/soar_auditing_provider/auditing_provider.rb', line 71 def warn(data, flow_identifier = nil) audit(:warn, data, flow_identifier) end |