Module: CmAppLogger
- Defined in:
- lib/cm_app_logger.rb
Overview
lib/cm_app_logger.rb
Class Method Summary collapse
Class Method Details
.error(label:, data: nil) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/cm_app_logger.rb', line 19 def self.error(label:, data: nil) = { label: label, data: data } Rails.logger.error(.to_json) end |
.log(label:, data: nil) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/cm_app_logger.rb', line 3 def self.log(label:, data: nil) = { label: label, data: data } start_time = Time.current Rails.logger.info(.to_json) return unless block_given? # Capture the block’s return value and return it to preserve existing behavior for callers expecting that value. block_result = yield [:start_time] = start_time [:duration_ms] = (Time.current - start_time) * 1000 Rails.logger.info(.to_json) block_result end |