Class: HTTPigeon::Logger
- Inherits:
-
Object
- Object
- HTTPigeon::Logger
- Defined in:
- lib/httpigeon/logger.rb
Instance Attribute Summary collapse
-
#end_time ⇒ Object
readonly
Returns the value of attribute end_time.
-
#event_type ⇒ Object
readonly
Returns the value of attribute event_type.
-
#log_redactor ⇒ Object
readonly
Returns the value of attribute log_redactor.
-
#start_time ⇒ Object
readonly
Returns the value of attribute start_time.
Instance Method Summary collapse
-
#initialize(event_type: nil, log_filters: nil) ⇒ Logger
constructor
A new instance of Logger.
- #log(faraday_env, data = {}) ⇒ Object
- #on_request_finish ⇒ Object
- #on_request_start ⇒ Object
Constructor Details
#initialize(event_type: nil, log_filters: nil) ⇒ Logger
Returns a new instance of Logger.
8 9 10 11 |
# File 'lib/httpigeon/logger.rb', line 8 def initialize(event_type: nil, log_filters: nil) @event_type = event_type || HTTPigeon.default_event_type @log_redactor = HTTPigeon.log_redactor || HTTPigeon::LogRedactor.new(log_filters: HTTPigeon.default_filter_keys | log_filters.to_a) end |
Instance Attribute Details
#end_time ⇒ Object (readonly)
Returns the value of attribute end_time.
6 7 8 |
# File 'lib/httpigeon/logger.rb', line 6 def end_time @end_time end |
#event_type ⇒ Object (readonly)
Returns the value of attribute event_type.
6 7 8 |
# File 'lib/httpigeon/logger.rb', line 6 def event_type @event_type end |
#log_redactor ⇒ Object (readonly)
Returns the value of attribute log_redactor.
6 7 8 |
# File 'lib/httpigeon/logger.rb', line 6 def log_redactor @log_redactor end |
#start_time ⇒ Object (readonly)
Returns the value of attribute start_time.
6 7 8 |
# File 'lib/httpigeon/logger.rb', line 6 def start_time @start_time end |
Instance Method Details
#log(faraday_env, data = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/httpigeon/logger.rb', line 13 def log(faraday_env, data = {}) base_log_data = { event_type: event_type } log_data = build_log_data(faraday_env, data).merge(base_log_data) HTTPigeon.event_logger.nil? ? log_to_stdout(log_data) : HTTPigeon.event_logger.log(log_data) rescue StandardError => e HTTPigeon.exception_notifier.notify_exception(e) if HTTPigeon.notify_all_exceptions raise e if ['development', 'test'].include?(ENV['RAILS_ENV'].to_s) end |
#on_request_finish ⇒ Object
27 28 29 |
# File 'lib/httpigeon/logger.rb', line 27 def on_request_finish @end_time = Time.current end |
#on_request_start ⇒ Object
23 24 25 |
# File 'lib/httpigeon/logger.rb', line 23 def on_request_start @start_time = Time.current end |