instance method add

Ruby on Rails edge

Since edge

Signature

add(severity, message = nil, progname = nil, &block)

Creates a log entry, which may or may not be written to the log, depending on the entry’s severity and on the log level.

Examples:

logger = ActiveSupport::ProxyLogger.new(Logger.new($stderr), :error)
logger.add(Logger::INFO, 'Will not show')
logger.add(Logger::ERROR, 'No good')
logger.add(Logger::ERROR, 'No good', 'gnum')

Output:

E, [2022-05-12T16:25:55.349414 #36328] ERROR -- mung: No good
E, [2022-05-12T16:26:35.841134 #36328] ERROR -- gnum: No good

These convenience methods have implicit severity:

Parameters

severity req
message opt = nil
progname opt = nil
block block
Source
# File activesupport/lib/active_support/proxy_logger.rb, line 146
    def add(severity, message = nil, progname = nil, &block)
      severity ||= UNKNOWN
      return true unless @logger && severity >= level

      if @ignored
        if message.nil?
          if block_given?
            message = yield
            block = nil
          else
            message = progname
            progname = nil
          end
        end

        text = message.to_s
        return true if text.valid_encoding? && @ignored.match?(text)
      end

      @logger.add(severity, message, progname, &block)
    end

Defined in activesupport/lib/active_support/proxy_logger.rb line 146 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveSupport::ProxyLogger

Type at least 2 characters to search.

Use the arrow keys to navigate results, Enter to open one, Escape to close.

Keyboard shortcuts

/
Focus search
⌘K / Ctrl-K
Command palette
?
This help
Esc
Close