Class: Sqlogger::Elite::Echo

Inherits:
Object
  • Object
show all
Defined in:
lib/sqlogger/elite/echo.rb

Class Method Summary collapse

Class Method Details

.post(opts = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/sqlogger/elite/echo.rb', line 7

def post opts={}
  return unless opts[:sql]
  echo_file = Sqlogger::Base.config.echo.file
  debug = Sqlogger::Base.config.echo.debug
  information = information_string_of opts

  echo_result = Open3.capture3 "echo \"#{information}\" >> #{echo_file}"
  if debug
    if echo_result.last.exitstatus == 0
      Rails.logger.info "Echo ok."
    else
      Rails.logger.error "Echo fail."
    end
  end
rescue => ex
  if debug
    Rails.logger.error ex.message
  end
end