Module: Rogu::Concern::Logging

Includes:
Logger::Severity
Defined in:
lib/rogu/concern/logging.rb

Overview

Enable logging where needed.

Modified version of the Concurrent::Concern::Logging module, without the timestamp field as it is automatically added by Heroku.

Instance Method Summary collapse

Instance Method Details

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

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

Parameters:

  • level (Integer)

    one of Logger::Severity 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



18
19
20
21
22
23
24
25
# File 'lib/rogu/concern/logging.rb', line 18

def log(level, progname, message = nil, &block)
  logger = ::Rogu.logger

  logger.call(level, progname, message, &block)
rescue => error
  $stderr.puts "`Rogu.logger` failed to log #{[level, progname, message, block]}\n" +
               "#{error.message} (#{error.class})\n#{error.backtrace.join "\n"}"
end