Class: EasyProfiler::Configuration
- Inherits:
-
Object
- Object
- EasyProfiler::Configuration
- Defined in:
- lib/easy_prof/configuration.rb
Instance Attribute Summary collapse
-
#colorize_logging ⇒ Object
Returns the value of attribute colorize_logging.
-
#count_ar_instances ⇒ Object
Value indicating whether profiler should log an approximate number of instantiated ActiveRecord objects.
-
#count_memory_usage ⇒ Object
Value indicating whether profiler should log an approximate amount of memory used.
-
#enable_profiling ⇒ Object
Value indicating whether profiling is globally enabled.
-
#live_logging ⇒ Object
Value indicating whether profiler should flush logs on every checkpoint.
-
#logger ⇒ Object
Gets a logger instance.
-
#print_limit ⇒ Object
Minimum time period which should be reached to dump profile to the log.
Class Method Summary collapse
Instance Method Summary collapse
- #disable_gc? ⇒ Boolean
- #enabled? ⇒ Boolean
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #merge(options = {}) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
29 30 31 32 33 34 35 36 37 |
# File 'lib/easy_prof/configuration.rb', line 29 def initialize @enable_profiling = false @print_limit = 0.01 @count_ar_instances = false @count_memory_usage = false @logger = nil @colorize_logging = false @live_logging = false end |
Instance Attribute Details
#colorize_logging ⇒ Object
Returns the value of attribute colorize_logging.
23 24 25 |
# File 'lib/easy_prof/configuration.rb', line 23 def colorize_logging @colorize_logging end |
#count_ar_instances ⇒ Object
Value indicating whether profiler should log an approximate number of instantiated ActiveRecord objects.
12 13 14 |
# File 'lib/easy_prof/configuration.rb', line 12 def count_ar_instances @count_ar_instances end |
#count_memory_usage ⇒ Object
Value indicating whether profiler should log an approximate amount of memory used.
16 17 18 |
# File 'lib/easy_prof/configuration.rb', line 16 def count_memory_usage @count_memory_usage end |
#enable_profiling ⇒ Object
Value indicating whether profiling is globally enabled.
4 5 6 |
# File 'lib/easy_prof/configuration.rb', line 4 def enable_profiling @enable_profiling end |
#live_logging ⇒ Object
Value indicating whether profiler should flush logs on every checkpoint.
27 28 29 |
# File 'lib/easy_prof/configuration.rb', line 27 def live_logging @live_logging end |
#logger ⇒ Object
Gets a logger instance.
When profiler is started inside Rails application, creates a “log/profile.log” files where all profile logs will be places. In regular scripts dumps information directly to STDOUT. You can use EasyProfiler.configuration.logger
to set another logger.
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/easy_prof/configuration.rb', line 86 def logger unless @logger @logger = if Object.const_defined?(:Rails) Logger.new(File.join(Rails.root, 'log', 'profile.log')) else Logger.new($stdout) end end @logger end |
#print_limit ⇒ Object
Minimum time period which should be reached to dump profile to the log.
8 9 10 |
# File 'lib/easy_prof/configuration.rb', line 8 def print_limit @print_limit end |
Class Method Details
.parse(config) ⇒ Object
111 112 113 114 115 116 117 118 119 120 |
# File 'lib/easy_prof/configuration.rb', line 111 def self.parse(config) case config when Hash EasyProfiler.configuration.merge(config) when EasyProfiler::Configuration config else EasyProfiler.configuration end end |
Instance Method Details
#disable_gc? ⇒ Boolean
122 123 124 |
# File 'lib/easy_prof/configuration.rb', line 122 def disable_gc? count_ar_instances or count_memory_usage end |
#enabled? ⇒ Boolean
126 127 128 |
# File 'lib/easy_prof/configuration.rb', line 126 def enabled? enable_profiling end |
#merge(options = {}) ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/easy_prof/configuration.rb', line 97 def merge( = {}) config = self.dup config.enable_profiling = [:enabled] if .has_key?(:enabled) config.enable_profiling = [:enable_profiling] if .has_key?(:enable_profiling) config.print_limit = [:limit] if .has_key?(:limit) config.print_limit = [:print_limit] if .has_key?(:print_limit) config.count_ar_instances = [:count_ar_instances] if .has_key?(:count_ar_instances) config.count_memory_usage = [:count_memory_usage] if .has_key?(:count_memory_usage) config.logger = [:logger] if .has_key?(:logger) config.colorize_logging = [:colorize_logging] if .has_key?(:colorize_logging) config.live_logging = [:live_logging] if .has_key?(:live_logging) config end |