Module: Lograge::Sql
- Defined in:
- lib/lograge/sql.rb,
lib/lograge/sql/railtie.rb,
lib/lograge/sql/version.rb,
lib/lograge/sql/extension.rb
Overview
Main gem module
Defined Under Namespace
Modules: Extension Classes: Railtie
Constant Summary collapse
- VERSION =
Gem version
'2.2.0'
Class Attribute Summary collapse
-
.extract_event ⇒ Object
Extract information from SQL event.
-
.formatter ⇒ Object
Format SQL log.
-
.min_duration_ms ⇒ Object
Filter SQL events by duration.
Class Method Summary collapse
-
.setup(config) ⇒ Object
Initialise configuration with fallback to default values.
-
.store ⇒ Hash, Thread
Gets the store, preferring RequestStore if the gem is found.
Class Attribute Details
.extract_event ⇒ Object
Extract information from SQL event
13 14 15 |
# File 'lib/lograge/sql.rb', line 13 def extract_event @extract_event end |
.formatter ⇒ Object
Format SQL log
11 12 13 |
# File 'lib/lograge/sql.rb', line 11 def formatter @formatter end |
.min_duration_ms ⇒ Object
Filter SQL events by duration
15 16 17 |
# File 'lib/lograge/sql.rb', line 15 def min_duration_ms @min_duration_ms end |
Class Method Details
.setup(config) ⇒ Object
Initialise configuration with fallback to default values
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/lograge/sql.rb', line 18 def setup(config) Lograge::Sql.formatter = config.formatter || default_formatter Lograge::Sql.extract_event = config.extract_event || default_extract_event Lograge::Sql.min_duration_ms = config.min_duration_ms || 0 # Disable existing ActiveRecord logging unsubscribe_log_subscribers unless config.keep_default_active_record_log return unless defined?(Lograge::ActiveRecordLogSubscriber) Lograge::ActiveRecordLogSubscriber.attach_to(:active_record) end |
.store ⇒ Hash, Thread
Gets the store, preferring RequestStore if the gem is found.
33 34 35 |
# File 'lib/lograge/sql.rb', line 33 def store defined?(RequestStore) ? RequestStore.store : Thread.current end |