Class: QueryOwl::FileLogger

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

Class Method Summary collapse

Class Method Details

.append(events) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/query_owl/file_logger.rb', line 7

def append(events)
  return if events.empty?

  path = QueryOwl.config.log_file
  return unless path

  FileUtils.mkdir_p(File.dirname(path))
  File.open(path, "a") do |f|
    events.each { |e| f.puts(JSON.generate(serializable(e))) }
  end
rescue => e
  Rails.logger.error "[QueryOwl] FileLogger failed: #{e.message}"
end