123456789_123456789_123456789_123456789_123456789_

Module: Concurrent::Concern::Logging

Overview

Include where logging is needed

Constant Summary

Instance Method Summary

Instance Method Details

#log(level, progname, message = nil, &block)

Logs through Concurrent.global_logger, it can be overridden by setting @logger

Parameters:

  • level (Integer)

    one of Logging constants

  • progname (String)

    e.g. a path of an Actor

  • message (String, nil) (defaults to: nil)

    when nil block is used to generate the message

Yield Returns:

  • (String)

    a message

[ GitHub ]

  
# File 'lib/concurrent-ruby/concurrent/concern/logging.rb', line 19

def log(level, progname, message = nil, &block)
  logger = if defined?(@logger) && @logger
             @logger
           else
             Concurrent.global_logger
           end
  logger.call level, progname, message, &block
rescue => error
  $stderr.puts "`Concurrent.global_logger` failed to log #{[level, progname, message, block]}\n" +
    "#{error.message} (#{error.class})\n#{error.backtrace.join "\n"}"
end