Module: RDF::Util::Logger::LoggerBehavior

Defined in:
vendor/bundler/ruby/2.5.0/bundler/gems/rdf-491e9bb5b443/lib/rdf/util/logger.rb

Overview

Module which is mixed-in to found logger to provide statistics and depth behavior

Since:

  • 2.0.0

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

Since:

  • 2.0.0



266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/rdf-491e9bb5b443/lib/rdf/util/logger.rb', line 266

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

Instance Attribute Details

#recoveringObject

Since:

  • 2.0.0



233
234
235
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/rdf-491e9bb5b443/lib/rdf/util/logger.rb', line 233

def recovering
  @recovering
end

Instance Method Details

#log_depth(options) { ... } ⇒ Object #log_depthInteger

Overloads:

  • #log_depth(options) { ... } ⇒ Object

    Increase depth around a method invocation

    Parameters:

    • depth (Integer)

      (1) recursion depth

    • options (Hash{Symbol})

      (@options || {})

    Options Hash (options):

    Yields:

    • Yields with no arguments

    Yield Returns:

    • (Object)

      returns the result of yielding

    Returns:

  • #log_depthInteger

    Return the current log depth

    Returns:

Since:

  • 2.0.0



253
254
255
256
257
258
259
260
261
262
263
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/rdf-491e9bb5b443/lib/rdf/util/logger.rb', line 253

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_statisticsObject

Since:

  • 2.0.0



235
236
237
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/rdf-491e9bb5b443/lib/rdf/util/logger.rb', line 235

def log_statistics
  @logger_statistics ||= {}
end

#respond_to_missing?(name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)

Since:

  • 2.0.0



282
283
284
285
286
287
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/rdf-491e9bb5b443/lib/rdf/util/logger.rb', line 282

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