module RDF::Util::Logger::LoggerBehavior
Module which is mixed-in to found logger to provide statistics and depth behavior
Attributes
recovering[RW]
Public Instance Methods
log_depth(options = {}) { || ... }
click to toggle source
@overload #log_depth(options, &block)
Increase depth around a method invocation @param [Hash{Symbol}] options (@options || {}) @option options [Integer] :depth (1) recursion depth @option options [Logger, #<<] :logger @yield Yields with no arguments @yieldreturn [Object] returns the result of yielding @return [Object]
@overload #log_depth
# Return the current log depth @return [Integer]
# File lib/rdf/util/logger.rb, line 247 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()
click to toggle source
# File lib/rdf/util/logger.rb, line 229 def log_statistics @logger_statistics ||= {} end
method_missing(method, *args)
click to toggle source
Give Logger like behavior to non-logger objects
Calls superclass method
# File lib/rdf/util/logger.rb, line 260 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 # Silently eat the message end when :level, :sev_threshold then 2 else super end end
respond_to_missing?(name, include_private = false)
click to toggle source
Calls superclass method
# File lib/rdf/util/logger.rb, line 276 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