module RDF::Util::Logger::LoggerBehavior
Module which is mixed-in to found logger to provide statistics and depth behavior
Attributes
Public Instance Methods
Source
# 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
@overload log_depth
(depth: 1, **options, &block)
Increase depth around a method invocation @param [Integer] depth (1) recursion depth @param [Hash{Symbol}] options (@options || {}) @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]
Source
# File lib/rdf/util/logger.rb, line 242 def log_statistics @logger_statistics ||= {} end
Source
# 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 # Silently eat the message end when :level, :sev_threshold then 2 else super end end
Give Logger
like behavior to non-logger objects
Calls superclass method
Source
# 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
Calls superclass method