Module: Lograge::Sql::Extension
- Defined in:
- lib/lograge/sql/extension.rb
Instance Method Summary collapse
Instance Method Details
#extract_request(event, payload) ⇒ Object
4 5 6 |
# File 'lib/lograge/sql/extension.rb', line 4 def extract_request(event, payload) super.merge!(extract_sql_queries(payload[:uuid], payload[:log_sql])) end |
#extract_sql_queries(uuid, log_sql) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/lograge/sql/extension.rb', line 8 def extract_sql_queries(uuid, log_sql) sql_queries = Thread.current[:lograge_sql_queries] return {} unless sql_queries return {} unless log_sql Thread.current[:lograge_sql_queries] = nil formatted_queries = if uuid queries_with_uuid = sql_queries.map do |query| "\n[#{uuid}] #{query}" end queries_with_uuid.join else sql_queries.join("\n") end { sql_queries: formatted_queries } end |