Class: Agentlog::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/agentlog/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

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

#enabledObject

Returns the value of attribute enabled.



5
6
7
# File 'lib/agentlog/configuration.rb', line 5

def enabled
  @enabled
end

#log_jobsObject

Returns the value of attribute log_jobs.



5
6
7
# File 'lib/agentlog/configuration.rb', line 5

def log_jobs
  @log_jobs
end

#log_paramsObject

Returns the value of attribute log_params.



5
6
7
# File 'lib/agentlog/configuration.rb', line 5

def log_params
  @log_params
end

#log_sqlObject

Returns the value of attribute log_sql.



5
6
7
# File 'lib/agentlog/configuration.rb', line 5

def log_sql
  @log_sql
end

#loggerObject

Returns the value of attribute logger.



5
6
7
# File 'lib/agentlog/configuration.rb', line 5

def logger
  @logger
end

#max_array_samplesObject

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_pairsObject

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

#pathObject

Returns the value of attribute path.



5
6
7
# File 'lib/agentlog/configuration.rb', line 5

def path
  @path
end

#preserve_keysObject

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_thresholdObject

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_msObject

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_formatObject

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

Returns:

  • (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