Module: DebugLogging
- Defined in:
- lib/debug_logging.rb,
lib/debug_logging/version.rb,
lib/debug_logging/class_logger.rb,
lib/debug_logging/configuration.rb,
lib/debug_logging/instance_logger.rb,
lib/debug_logging/argument_printer.rb,
lib/debug_logging/instance_logger_modulizer.rb
Overview
# NOTE: The manner this is made to work for class methods is totally different
than the way this is made to work for instance methods.
NOTE: The instance method manner works on Ruby 2.0+ NOTE: The class method manner works on Ruby 2.1+
USAGE (see specs)#
class Car
extend DebugLogging
self.debug_class_benchmarks = true
self.debug_instance_benchmarks = true
include DebugLogging::InstanceLogger.new(i_methods: [:drive, :stop])
extend DebugLogging::ClassLogger
logged def debug_make; new; end
def design(*args); new; end
def safety(*args); new; end
logged :design, :safety
def drive(speed); speed; end
def stop; 0; end
include DebugLogging::InstanceLogger.new(i_methods: self.instance_methods(false))
def will_not_be_logged; false; end
end
Defined Under Namespace
Modules: ArgumentPrinter, ClassLogger, InstanceLoggerModulizer
Classes: Configuration, InstanceLogger
Constant Summary
collapse
- VERSION =
'3.0.0'
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Class Attribute Details
.debug_logging_configuration ⇒ Object
Returns the value of attribute debug_logging_configuration.
103
104
105
|
# File 'lib/debug_logging.rb', line 103
def debug_logging_configuration
@debug_logging_configuration
end
|
Class Method Details
.configuration ⇒ Object
For single statement global config in an initializer e.g. DebugLogging.configuration.ellipsis = “…”
86
87
88
|
# File 'lib/debug_logging.rb', line 86
def self.configuration
self.debug_logging_configuration ||= Configuration.new
end
|
For global config in an initializer with a block
91
92
93
|
# File 'lib/debug_logging.rb', line 91
def self.configure
yield(configuration)
end
|
.extended(base) ⇒ Object
61
62
63
64
|
# File 'lib/debug_logging.rb', line 61
def self.extended(base)
base.send(:extend, ArgumentPrinter)
base.debug_config_reset(Configuration.new(**debug_logging_configuration.to_hash))
end
|
Instance Method Details
#debug_add_invocation_id ⇒ Object
197
198
199
|
# File 'lib/debug_logging.rb', line 197
def debug_add_invocation_id
@debug_logging_configuration.add_invocation_id
end
|
#debug_add_invocation_id=(add_invocation_id) ⇒ Object
201
202
203
|
# File 'lib/debug_logging.rb', line 201
def debug_add_invocation_id=(add_invocation_id)
@debug_logging_configuration.add_invocation_id = add_invocation_id
end
|
#debug_args_max_length ⇒ Object
157
158
159
|
# File 'lib/debug_logging.rb', line 157
def debug_args_max_length
@debug_logging_configuration.args_max_length
end
|
#debug_args_max_length=(args_max_length) ⇒ Object
161
162
163
|
# File 'lib/debug_logging.rb', line 161
def debug_args_max_length=(args_max_length)
@debug_logging_configuration.args_max_length = args_max_length
end
|
#debug_class_benchmarks ⇒ Object
173
174
175
|
# File 'lib/debug_logging.rb', line 173
def debug_class_benchmarks
@debug_logging_configuration.class_benchmarks
end
|
#debug_class_benchmarks=(class_benchmarks) ⇒ Object
177
178
179
|
# File 'lib/debug_logging.rb', line 177
def debug_class_benchmarks=(class_benchmarks)
@debug_logging_configuration.class_benchmarks = class_benchmarks
end
|
#debug_colorized_chain_for_class ⇒ Object
189
190
191
|
# File 'lib/debug_logging.rb', line 189
def debug_colorized_chain_for_class
@debug_logging_configuration.colorized_chain_for_class
end
|
#debug_colorized_chain_for_class=(colorized_chain_for_class) ⇒ Object
193
194
195
|
# File 'lib/debug_logging.rb', line 193
def debug_colorized_chain_for_class=(colorized_chain_for_class)
@debug_logging_configuration.colorized_chain_for_class = colorized_chain_for_class
end
|
#debug_colorized_chain_for_method ⇒ Object
181
182
183
|
# File 'lib/debug_logging.rb', line 181
def debug_colorized_chain_for_method
@debug_logging_configuration.colorized_chain_for_method
end
|
#debug_colorized_chain_for_method=(colorized_chain_for_method) ⇒ Object
185
186
187
|
# File 'lib/debug_logging.rb', line 185
def debug_colorized_chain_for_method=(colorized_chain_for_method)
@debug_logging_configuration.colorized_chain_for_method = colorized_chain_for_method
end
|
#debug_config ⇒ Object
There are times when the class will need access to the configuration object,
such as to override it per instance method
80
81
82
|
# File 'lib/debug_logging.rb', line 80
def debug_config
@debug_logging_configuration
end
|
#debug_config_reset(config = Configuration.new) ⇒ Object
105
106
107
|
# File 'lib/debug_logging.rb', line 105
def debug_config_reset(config = Configuration.new)
@debug_logging_configuration = config
end
|
#debug_ellipsis ⇒ Object
213
214
215
|
# File 'lib/debug_logging.rb', line 213
def debug_ellipsis
@debug_logging_configuration.ellipsis
end
|
#debug_ellipsis=(ellipsis) ⇒ Object
217
218
219
|
# File 'lib/debug_logging.rb', line 217
def debug_ellipsis=(ellipsis)
@debug_logging_configuration.ellipsis = ellipsis
end
|
#debug_enabled ⇒ Object
109
110
111
|
# File 'lib/debug_logging.rb', line 109
def debug_enabled
@debug_logging_configuration.enabled
end
|
#debug_enabled=(value) ⇒ Object
113
114
115
|
# File 'lib/debug_logging.rb', line 113
def debug_enabled=(value)
@debug_logging_configuration.enabled = value
end
|
#debug_instance_benchmarks ⇒ Object
165
166
167
|
# File 'lib/debug_logging.rb', line 165
def debug_instance_benchmarks
@debug_logging_configuration.instance_benchmarks
end
|
#debug_instance_benchmarks=(instance_benchmarks) ⇒ Object
169
170
171
|
# File 'lib/debug_logging.rb', line 169
def debug_instance_benchmarks=(instance_benchmarks)
@debug_logging_configuration.instance_benchmarks = instance_benchmarks
end
|
#debug_last_hash_max_length ⇒ Object
149
150
151
|
# File 'lib/debug_logging.rb', line 149
def debug_last_hash_max_length
@debug_logging_configuration.last_hash_max_length
end
|
#debug_last_hash_max_length=(last_hash_max_length) ⇒ Object
153
154
155
|
# File 'lib/debug_logging.rb', line 153
def debug_last_hash_max_length=(last_hash_max_length)
@debug_logging_configuration.last_hash_max_length = last_hash_max_length
end
|
#debug_last_hash_to_s_proc ⇒ Object
141
142
143
|
# File 'lib/debug_logging.rb', line 141
def debug_last_hash_to_s_proc
@debug_logging_configuration.last_hash_to_s_proc
end
|
#debug_last_hash_to_s_proc=(last_hash_to_s_proc) ⇒ Object
145
146
147
|
# File 'lib/debug_logging.rb', line 145
def debug_last_hash_to_s_proc=(last_hash_to_s_proc)
@debug_logging_configuration.last_hash_to_s_proc = last_hash_to_s_proc
end
|
#debug_log(message = nil, config_proxy = nil, &block) ⇒ Object
API #### Not used by this gem internally, but provides an external interface for
classes to also use this logging tool directly,
with configured options like benchmarking, colors, or leg level.
70
71
72
73
74
75
76
|
# File 'lib/debug_logging.rb', line 70
def debug_log(message = nil, config_proxy = nil, &block)
config_proxy ||= debug_config
config_proxy.log(message, &block)
end
|
#debug_log_level ⇒ Object
125
126
127
|
# File 'lib/debug_logging.rb', line 125
def debug_log_level
@debug_logging_configuration.log_level
end
|
#debug_log_level=(log_level) ⇒ Object
129
130
131
|
# File 'lib/debug_logging.rb', line 129
def debug_log_level=(log_level)
@debug_logging_configuration.log_level = log_level
end
|
#debug_logger ⇒ Object
117
118
119
|
# File 'lib/debug_logging.rb', line 117
def debug_logger
@debug_logging_configuration.logger
end
|
#debug_logger=(logger) ⇒ Object
121
122
123
|
# File 'lib/debug_logging.rb', line 121
def debug_logger=(logger)
@debug_logging_configuration.logger = logger
end
|
For per-class config with a block
96
97
98
99
|
# File 'lib/debug_logging.rb', line 96
def debug_logging_configure
@debug_logging_configuration ||= Configuration.new
yield(@debug_logging_configuration)
end
|
#debug_mark_scope_exit ⇒ Object
205
206
207
|
# File 'lib/debug_logging.rb', line 205
def debug_mark_scope_exit
@debug_logging_configuration.mark_scope_exit
end
|
#debug_mark_scope_exit=(mark_scope_exit) ⇒ Object
209
210
211
|
# File 'lib/debug_logging.rb', line 209
def debug_mark_scope_exit=(mark_scope_exit)
@debug_logging_configuration.mark_scope_exit = mark_scope_exit
end
|
#debug_multiple_last_hashes ⇒ Object
133
134
135
|
# File 'lib/debug_logging.rb', line 133
def debug_multiple_last_hashes
@debug_logging_configuration.multiple_last_hashes
end
|
#debug_multiple_last_hashes=(multiple_last_hashes) ⇒ Object
137
138
139
|
# File 'lib/debug_logging.rb', line 137
def debug_multiple_last_hashes=(multiple_last_hashes)
@debug_logging_configuration.multiple_last_hashes = multiple_last_hashes
end
|