Class: Agentlog::Configuration
- Inherits:
-
Object
- Object
- Agentlog::Configuration
- Defined in:
- lib/agentlog/configuration.rb
Instance Attribute Summary collapse
-
#enabled ⇒ Object
Returns the value of attribute enabled.
-
#log_jobs ⇒ Object
Returns the value of attribute log_jobs.
-
#log_params ⇒ Object
Returns the value of attribute log_params.
-
#log_sql ⇒ Object
Returns the value of attribute log_sql.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#max_array_samples ⇒ Object
Returns the value of attribute max_array_samples.
-
#max_hash_pairs ⇒ Object
Returns the value of attribute max_hash_pairs.
-
#path ⇒ Object
Returns the value of attribute path.
-
#preserve_keys ⇒ Object
Returns the value of attribute preserve_keys.
-
#repeat_sql_threshold ⇒ Object
Returns the value of attribute repeat_sql_threshold.
-
#slow_sql_ms ⇒ Object
Returns the value of attribute slow_sql_ms.
-
#time_format ⇒ Object
Returns the value of attribute time_format.
Instance Method Summary collapse
- #enabled?(environment = nil) ⇒ Boolean
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/agentlog/configuration.rb', line 18 def initialize @enabled = nil @logger = nil @log_jobs = true @log_params = true @log_sql = true @max_array_samples = 1 @max_hash_pairs = 6 @path = "log/agent.log" @preserve_keys = [] @repeat_sql_threshold = 3 @slow_sql_ms = 25.0 @time_format = "%H:%M:%S" end |
Instance Attribute Details
#enabled ⇒ Object
Returns the value of attribute enabled.
5 6 7 |
# File 'lib/agentlog/configuration.rb', line 5 def enabled @enabled end |
#log_jobs ⇒ Object
Returns the value of attribute log_jobs.
5 6 7 |
# File 'lib/agentlog/configuration.rb', line 5 def log_jobs @log_jobs end |
#log_params ⇒ Object
Returns the value of attribute log_params.
5 6 7 |
# File 'lib/agentlog/configuration.rb', line 5 def log_params @log_params end |
#log_sql ⇒ Object
Returns the value of attribute log_sql.
5 6 7 |
# File 'lib/agentlog/configuration.rb', line 5 def log_sql @log_sql end |
#logger ⇒ Object
Returns the value of attribute logger.
5 6 7 |
# File 'lib/agentlog/configuration.rb', line 5 def logger @logger end |
#max_array_samples ⇒ Object
Returns the value of attribute max_array_samples.
5 6 7 |
# File 'lib/agentlog/configuration.rb', line 5 def max_array_samples @max_array_samples end |
#max_hash_pairs ⇒ Object
Returns the value of attribute max_hash_pairs.
5 6 7 |
# File 'lib/agentlog/configuration.rb', line 5 def max_hash_pairs @max_hash_pairs end |
#path ⇒ Object
Returns the value of attribute path.
5 6 7 |
# File 'lib/agentlog/configuration.rb', line 5 def path @path end |
#preserve_keys ⇒ Object
Returns the value of attribute preserve_keys.
5 6 7 |
# File 'lib/agentlog/configuration.rb', line 5 def preserve_keys @preserve_keys end |
#repeat_sql_threshold ⇒ Object
Returns the value of attribute repeat_sql_threshold.
5 6 7 |
# File 'lib/agentlog/configuration.rb', line 5 def repeat_sql_threshold @repeat_sql_threshold end |
#slow_sql_ms ⇒ Object
Returns the value of attribute slow_sql_ms.
5 6 7 |
# File 'lib/agentlog/configuration.rb', line 5 def slow_sql_ms @slow_sql_ms end |
#time_format ⇒ Object
Returns the value of attribute time_format.
5 6 7 |
# File 'lib/agentlog/configuration.rb', line 5 def time_format @time_format end |
Instance Method Details
#enabled?(environment = nil) ⇒ Boolean
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/agentlog/configuration.rb', line 33 def enabled?(environment = nil) return enabled unless enabled.nil? env_name = if environment.respond_to?(:to_s) environment.to_s elsif defined?(Rails) && Rails.respond_to?(:env) Rails.env.to_s end %w[development test].include?(env_name) end |