Class: ActiveRecord::SqlAnalyzer::Logger
- Inherits:
-
Object
- Object
- ActiveRecord::SqlAnalyzer::Logger
- Defined in:
- lib/active_record/sql_analyzer/logger.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#log_file ⇒ Object
readonly
Returns the value of attribute log_file.
-
#log_prefix ⇒ Object
readonly
Returns the value of attribute log_prefix.
-
#log_root ⇒ Object
readonly
Returns the value of attribute log_root.
Instance Method Summary collapse
- #close ⇒ Object
-
#filter_event(event) ⇒ Object
Further redact or remove any other information from an event.
-
#initialize(log_root, log_prefix) ⇒ Logger
constructor
A new instance of Logger.
-
#log(event) ⇒ Object
Log the raw event data directly to disk.
Constructor Details
#initialize(log_root, log_prefix) ⇒ Logger
Returns a new instance of Logger.
6 7 8 9 10 11 12 |
# File 'lib/active_record/sql_analyzer/logger.rb', line 6 def initialize(log_root, log_prefix) @log_prefix = log_prefix @log_root = log_root @config = SqlAnalyzer.config @log_file = File.open("#{log_root}/#{log_prefix}.log", "a") end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
4 5 6 |
# File 'lib/active_record/sql_analyzer/logger.rb', line 4 def config @config end |
#log_file ⇒ Object (readonly)
Returns the value of attribute log_file.
4 5 6 |
# File 'lib/active_record/sql_analyzer/logger.rb', line 4 def log_file @log_file end |
#log_prefix ⇒ Object (readonly)
Returns the value of attribute log_prefix.
4 5 6 |
# File 'lib/active_record/sql_analyzer/logger.rb', line 4 def log_prefix @log_prefix end |
#log_root ⇒ Object (readonly)
Returns the value of attribute log_root.
4 5 6 |
# File 'lib/active_record/sql_analyzer/logger.rb', line 4 def log_root @log_root end |
Instance Method Details
#close ⇒ Object
24 25 26 |
# File 'lib/active_record/sql_analyzer/logger.rb', line 24 def close @log_file.close rescue nil end |
#filter_event(event) ⇒ Object
Further redact or remove any other information from an event
20 21 22 |
# File 'lib/active_record/sql_analyzer/logger.rb', line 20 def filter_event(event) event end |
#log(event) ⇒ Object
Log the raw event data directly to disk
15 16 17 |
# File 'lib/active_record/sql_analyzer/logger.rb', line 15 def log(event) log_file.puts(event.to_json) end |