Sha256: c802644124c60ff4a69557723f873f118c089413c727d66e233f6beab4c62103

Contents?: true

Size: 549 Bytes

Versions: 1

Compression:

Stored size: 549 Bytes

Contents

# Logs DB queries in console
# to active just load the file
logger = Logger.new(STDOUT)

logger.formatter = proc { |severity, datetime, progname, msg|
  elms = msg.split(/\(|s\)\s/, 3)
  time = (elms[1].to_f * 1000).round(1)
  if Thread.current[:db_q]
    Thread.current[:db_q][:time] += elms[1].to_f
    Thread.current[:db_q][:cnt] += 1

    # append debug=true as query-string to see database queries
    Lux.log(" #{Thread.current[:db_q][:cnt].to_s.rjust(2)}. #{time} : #{elms[2].cyan}\n") if Thread.current[:db_q]
  end
}

DB.loggers << logger

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lux-fw-0.1.17 ./lib/plugins/db_logger/init.rb