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, DebugLogging::Constants::DEFAULT_TIME_FORMATTER, DebugLogging::Constants::EVENT_TIME_FORMATTER
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Configuration.
50
51
52
53
54
55
56
57
58
|
# File 'lib/debug_logging/configuration.rb', line 50
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, decorated_method) ⇒ Object
42
43
44
45
46
47
|
# File 'lib/debug_logging/configuration.rb', line 42
def config_pointer(type, decorated_method)
"@debug_logging_config_#{type}_#{Digest::MD5.hexdigest(decorated_method.to_s)}".to_sym
end
|
Instance Method Details
#active_support_notifications=(active_support_notifications) ⇒ Object
99
100
101
102
|
# File 'lib/debug_logging/configuration.rb', line 99
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
77
78
79
80
81
|
# File 'lib/debug_logging/configuration.rb', line 77
def benchmarkable_for?(benchmarks)
return @benchmarkable if defined?(@benchmarkable)
@benchmarkable = loggable? && send(benchmarks)
end
|
#class_benchmarks=(class_benchmarks) ⇒ Object
94
95
96
97
|
# File 'lib/debug_logging/configuration.rb', line 94
def class_benchmarks=(class_benchmarks)
require "benchmark" if class_benchmarks
@class_benchmarks = class_benchmarks
end
|
#exit_scope_markable? ⇒ Boolean
83
84
85
86
87
|
# File 'lib/debug_logging/configuration.rb', line 83
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
89
90
91
92
|
# File 'lib/debug_logging/configuration.rb', line 89
def instance_benchmarks=(instance_benchmarks)
require "benchmark" if instance_benchmarks
@instance_benchmarks = instance_benchmarks
end
|
#log(message = nil, &block) ⇒ Object
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/debug_logging/configuration.rb', line 60
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
71
72
73
74
75
|
# File 'lib/debug_logging/configuration.rb', line 71
def loggable?
return @loggable if defined?(@loggable)
@loggable = logger.send(:"#{log_level}?")
end
|
#register(method_lo_log) ⇒ Object
110
111
112
|
# File 'lib/debug_logging/configuration.rb', line 110
def register(method_lo_log)
@methods_to_log << method_lo_log
end
|
#to_hash ⇒ Object
104
105
106
107
108
|
# File 'lib/debug_logging/configuration.rb', line 104
def to_hash
CONFIG_KEYS.each_with_object({}) do |key, hash|
hash[key] = instance_variable_get(:"@#{key}")
end
end
|