Class: StreamAuditor
- Inherits:
-
SoarAuditorApi::AuditorAPI
- Object
- SoarAuditorApi::AuditorAPI
- StreamAuditor
- Defined in:
- lib/stream_auditor.rb,
lib/stream_auditor/version.rb
Overview
An IO stream (or file) implementation of SoarAuditorApi::AuditorAPI
This implementation supports auditing to:
-
an already open
IO
object (or anything that implements IO#<< and IO#flush), -
the standard error stream ($stderr),
-
the standard output stream ($stdout), or
-
a file.
Developers should not need to work directly with this class. Instead, they should configure it through the SOAR auditing provider.
Constant Summary collapse
- VERSION =
"1.2.1"
Instance Method Summary collapse
-
#audit(data) ⇒ Object
Write data to the configured stream.
-
#configuration_is_valid?(configuration) ⇒ true, false
Validates the configuration.
-
#configure(configuration = nil) ⇒ Object
Apply the configuration supplied to initialize.
-
#prefer_direct_call? ⇒ true
Hint direct auditor call preference to SOAR Auditor API.
Instance Method Details
#audit(data) ⇒ Object
Write data to the configured stream
The stream is immediately flushed after the data is written.
51 52 53 54 |
# File 'lib/stream_auditor.rb', line 51 def audit(data) stream << data.to_s.chomp + "\n" stream.flush end |
#configuration_is_valid?(configuration) ⇒ true, false
Validates the configuration
104 105 106 107 108 109 |
# File 'lib/stream_auditor.rb', line 104 def configuration_is_valid?(configuration) return false unless (configuration.keys - ["adaptor", "nfrs", "stream"]).empty? s = configuration["stream"] want_default_stream?(s) or want_stderr_stream?(s) or want_stdout_stream?(s) or want_io_stream?(s) or want_path_stream?(s) end |
#configure(configuration = nil) ⇒ Object
Apply the configuration supplied to initialize
81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/stream_auditor.rb', line 81 def configure(configuration = nil) super if configuration s = configuration["stream"] @stream = if want_stdout_stream?(s) then $stdout elsif want_stderr_stream?(s) then $stderr elsif want_io_stream?(s) then s elsif want_path_stream?(s) then creative_open_file(s) end end end |
#prefer_direct_call? ⇒ true
Hint direct auditor call preference to SOAR Auditor API
116 117 118 |
# File 'lib/stream_auditor.rb', line 116 def prefer_direct_call? true end |