Class: RailsMemoryProfiler::Notifiers::FileLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_memory_profiler/notifiers/file_logger.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ FileLogger

Returns a new instance of FileLogger.



6
7
8
# File 'lib/rails_memory_profiler/notifiers/file_logger.rb', line 6

def initialize(path)
  @path = path
end

Instance Method Details

#call(report) ⇒ Object



10
11
12
13
# File 'lib/rails_memory_profiler/notifiers/file_logger.rb', line 10

def call(report)
  serializable = report.merge(recorded_at: report[:recorded_at]&.iso8601)
  File.open(@path, "a") { |f| f.puts(serializable.to_json) }
end