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 }
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.
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/soar_auditing_provider/auditing_provider.rb', line 27 def initialize(configuration) validate_provider_configuration(configuration) @configuration = configuration @flow_id_generator = @configuration["flow_id_generator"] || DEFAULT_FLOW_ID_GENERATOR super(create_auditors(configuration)) select_auditor(configuration['default_nfrs']) 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.
24 25 26 |
# File 'lib/soar_auditing_provider/auditing_provider.rb', line 24 def configuration @configuration end |
#service_identifier ⇒ Object
Returns the value of attribute service_identifier.
23 24 25 |
# File 'lib/soar_auditing_provider/auditing_provider.rb', line 23 def service_identifier @service_identifier end |
#startup_flow_id ⇒ Object
39 40 41 |
# File 'lib/soar_auditing_provider/auditing_provider.rb', line 39 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
87 88 89 90 91 92 93 |
# File 'lib/soar_auditing_provider/auditing_provider.rb', line 87 def audit_exception(exception:, level: :error, flow_id: nil, message: nil) = "#{exception.class}: #{exception.message}" = "#{message} - #{exception_message}" 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
55 56 57 |
# File 'lib/soar_auditing_provider/auditing_provider.rb', line 55 def debug(data, flow_identifier = nil) audit(:debug, data, flow_identifier) end |
#detailed_status ⇒ Object
77 78 79 80 81 |
# File 'lib/soar_auditing_provider/auditing_provider.rb', line 77 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
69 70 71 |
# File 'lib/soar_auditing_provider/auditing_provider.rb', line 69 def error(data, flow_identifier = nil) audit(:error, data, flow_identifier) end |
#fatal(data, flow_identifier = nil) ⇒ Object
73 74 75 |
# File 'lib/soar_auditing_provider/auditing_provider.rb', line 73 def fatal(data, flow_identifier = nil) audit(:fatal, data, flow_identifier) end |
#flush(timeout: 1) ⇒ Object
83 84 85 |
# File 'lib/soar_auditing_provider/auditing_provider.rb', line 83 def flush(timeout: 1) @worker.flush(timeout: timeout) end |
#info(data, flow_identifier = nil) ⇒ Object Also known as: <<
59 60 61 |
# File 'lib/soar_auditing_provider/auditing_provider.rb', line 59 def info(data, flow_identifier = nil) audit(:info, data, flow_identifier) end |
#select_auditor(nfrs) ⇒ Object
43 44 45 46 |
# File 'lib/soar_auditing_provider/auditing_provider.rb', line 43 def select_auditor(nfrs) select(nfrs) set_audit_level(@configuration['level'].to_sym) end |
#set_audit_level(level) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/soar_auditing_provider/auditing_provider.rb', line 48 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
65 66 67 |
# File 'lib/soar_auditing_provider/auditing_provider.rb', line 65 def warn(data, flow_identifier = nil) audit(:warn, data, flow_identifier) end |