Class: DebugLogging::Configuration
- Inherits:
-
Object
- Object
- DebugLogging::Configuration
show all
- Includes:
- Constants
- Defined in:
- lib/debug_logging/configuration.rb
Constant Summary
Constants included
from Constants
DebugLogging::Constants::CONFIG_ATTRS, DebugLogging::Constants::CONFIG_ATTRS_DEFAULTS, DebugLogging::Constants::CONFIG_KEYS, DebugLogging::Constants::CONFIG_READERS, DebugLogging::Constants::CONFIG_READERS_DEFAULTS, DebugLogging::Constants::DEFAULT_ELLIPSIS
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Configuration.
42
43
44
45
46
47
48
49
50
|
# File 'lib/debug_logging/configuration.rb', line 42
def initialize(**options)
CONFIG_ATTRS.each do |key|
send("#{key}=", get_attr_from_options(options, key))
end
CONFIG_READERS.each do |key|
send("#{key}=", get_reader_from_options(options, key))
end
@methods_to_log = []
end
|
Class Method Details
.config_pointer(type, method_to_log) ⇒ Object
35
36
37
38
39
40
|
# File 'lib/debug_logging/configuration.rb', line 35
def config_pointer(type, method_to_log)
"@debug_logging_config_#{type}_#{Digest::MD5.hexdigest(method_to_log.to_s)}".to_sym
end
|
Instance Method Details
#active_support_notifications=(active_support_notifications) ⇒ Object
91
92
93
94
|
# File 'lib/debug_logging/configuration.rb', line 91
def active_support_notifications=(active_support_notifications)
require 'debug_logging/active_support_notifications' if active_support_notifications
@active_support_notifications = active_support_notifications
end
|
#benchmarkable_for?(benchmarks) ⇒ Boolean
69
70
71
72
73
|
# File 'lib/debug_logging/configuration.rb', line 69
def benchmarkable_for?(benchmarks)
return @benchmarkable if defined?(@benchmarkable)
@benchmarkable = loggable? && send(benchmarks)
end
|
#class_benchmarks=(class_benchmarks) ⇒ Object
86
87
88
89
|
# File 'lib/debug_logging/configuration.rb', line 86
def class_benchmarks=(class_benchmarks)
require 'benchmark' if class_benchmarks
@class_benchmarks = class_benchmarks
end
|
#exit_scope_markable? ⇒ Boolean
75
76
77
78
79
|
# File 'lib/debug_logging/configuration.rb', line 75
def exit_scope_markable?
return @exit_scope_markable if defined?(@exit_scope_markable)
@exit_scope_markable = loggable? && mark_scope_exit
end
|
#instance_benchmarks=(instance_benchmarks) ⇒ Object
81
82
83
84
|
# File 'lib/debug_logging/configuration.rb', line 81
def instance_benchmarks=(instance_benchmarks)
require 'benchmark' if instance_benchmarks
@instance_benchmarks = instance_benchmarks
end
|
#log(message = nil, &block) ⇒ Object
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/debug_logging/configuration.rb', line 52
def log(message = nil, &block)
return unless enabled
return unless logger
if block
logger.send(log_level, &block)
else
logger.send(log_level, message)
end
end
|
#loggable? ⇒ Boolean
63
64
65
66
67
|
# File 'lib/debug_logging/configuration.rb', line 63
def loggable?
return @loggable if defined?(@loggable)
@loggable = logger.send("#{log_level}?")
end
|
#register(method_lo_log) ⇒ Object
102
103
104
|
# File 'lib/debug_logging/configuration.rb', line 102
def register(method_lo_log)
@methods_to_log << method_lo_log
end
|
#to_hash ⇒ Object
96
97
98
99
100
|
# File 'lib/debug_logging/configuration.rb', line 96
def to_hash
CONFIG_KEYS.each_with_object({}) do |key, hash|
hash[key] = instance_variable_get("@#{key}")
end
end
|