Module: RDF::Util::Logger::LoggerBehavior
- Defined in:
- lib/rdf/util/logger.rb
Overview
Module which is mixed-in to found logger to provide statistics and depth behavior
Instance Attribute Summary collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
Give Logger like behavior to non-logger objects
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
|
# File 'lib/rdf/util/logger.rb', line 261
def method_missing(method, *args)
case method.to_sym
when :fatal, :error, :warn, :info, :debug
if self.respond_to?(:write)
self.write "#{method.to_s.upcase} #{(args.join(": "))}\n"
elsif self.respond_to?(:<<)
self << "#{method.to_s.upcase} #{args.join(": ")}"
else
end
when :level, :sev_threshold then 2
else
super
end
end
|
Instance Attribute Details
#recovering ⇒ Object
228
229
230
|
# File 'lib/rdf/util/logger.rb', line 228
def recovering
@recovering
end
|
Instance Method Details
#log_depth(options) { ... } ⇒ Object
#log_depth ⇒ Integer
248
249
250
251
252
253
254
255
256
257
258
|
# File 'lib/rdf/util/logger.rb', line 248
def log_depth(options = {})
@log_depth ||= 0
if block_given?
@log_depth += options.fetch(:depth, 1)
yield
else
@log_depth
end
ensure
@log_depth -= options.fetch(:depth, 1) if block_given?
end
|
#log_statistics ⇒ Object
230
231
232
|
# File 'lib/rdf/util/logger.rb', line 230
def log_statistics
@logger_statistics ||= {}
end
|
#respond_to_missing?(name, include_private = false) ⇒ Boolean
277
278
279
280
281
282
|
# File 'lib/rdf/util/logger.rb', line 277
def respond_to_missing?(name, include_private = false)
return true if
[:fatal, :error, :warn, :info, :debug, :level, :sev_threshold]
.include?(name.to_sym)
super
end
|