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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
|
# File 'lib/rdf/util/logger.rb', line 273
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
240
241
242
|
# File 'lib/rdf/util/logger.rb', line 240
def recovering
@recovering
end
|
Instance Method Details
#log_depth(depth: 1, **options) { ... } ⇒ Object
#log_depth ⇒ Integer
260
261
262
263
264
265
266
267
268
269
270
|
# File 'lib/rdf/util/logger.rb', line 260
def log_depth(depth: 1, **options)
@log_depth ||= 0
if block_given?
@log_depth += depth
yield
else
@log_depth
end
ensure
@log_depth -= depth if block_given?
end
|
#log_statistics ⇒ Object
242
243
244
|
# File 'lib/rdf/util/logger.rb', line 242
def log_statistics
@logger_statistics ||= {}
end
|
#respond_to_missing?(name, include_private = false) ⇒ Boolean
289
290
291
292
293
294
|
# File 'lib/rdf/util/logger.rb', line 289
def respond_to_missing?(name, include_private = false)
return true if
%i(fatal error warn info debug level sev_threshold)
.include?(name.to_sym)
super
end
|