Sha256: d572bee0e551a965c6f0a06bcb39dff29c3532376bebc86b5e355746cd7e1f2b

Contents?: true

Size: 1.27 KB

Versions: 32

Compression:

Stored size: 1.27 KB

Contents

# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
# frozen_string_literal: true

# Base class for startup logging and testing in multiverse

require 'new_relic/agent/log_once'

module NewRelic
  module Agent
    class MemoryLogger
      include LogOnce

      def initialize
        @already_logged_lock = Mutex.new
        clear_already_logged

        @messages = []
      end

      def is_startup_logger?
        true
      end

      attr_accessor :messages, :level, :log_formatter

      def fatal(*msgs, &blk)
        messages << [:fatal, msgs, blk]
      end

      def error(*msgs, &blk)
        messages << [:error, msgs, blk]
      end

      def warn(*msgs, &blk)
        messages << [:warn, msgs, blk]
      end

      def info(*msgs, &blk)
        messages << [:info, msgs, blk]
      end

      def debug(*msgs, &blk)
        messages << [:debug, msgs, blk]
      end

      def log_exception(level, e, backtrace_level = level)
        messages << [:log_exception, [level, e, backtrace_level]]
      end

      def dump(logger)
        messages.each do |(method, args, blk)|
          logger.send(method, *args, &blk)
        end
        messages.clear
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
newrelic_rpm-9.16.0 lib/new_relic/agent/memory_logger.rb
newrelic_rpm-9.15.0 lib/new_relic/agent/memory_logger.rb
newrelic_rpm-9.14.0 lib/new_relic/agent/memory_logger.rb
newrelic_rpm-9.13.0 lib/new_relic/agent/memory_logger.rb
newrelic_rpm-9.12.0 lib/new_relic/agent/memory_logger.rb
newrelic_rpm-9.11.0 lib/new_relic/agent/memory_logger.rb
newrelic_rpm-9.10.2 lib/new_relic/agent/memory_logger.rb
newrelic_rpm-9.10.1 lib/new_relic/agent/memory_logger.rb
newrelic_rpm-9.10.0 lib/new_relic/agent/memory_logger.rb
newrelic_rpm-9.9.0 lib/new_relic/agent/memory_logger.rb
newrelic_rpm-9.8.0 lib/new_relic/agent/memory_logger.rb
newrelic_rpm-9.7.1 lib/new_relic/agent/memory_logger.rb
newrelic_rpm-9.7.0 lib/new_relic/agent/memory_logger.rb
newrelic_rpm-9.6.0 lib/new_relic/agent/memory_logger.rb
newrelic_rpm-9.5.0 lib/new_relic/agent/memory_logger.rb
newrelic_rpm-9.4.2 lib/new_relic/agent/memory_logger.rb
newrelic_rpm-9.4.1 lib/new_relic/agent/memory_logger.rb
newrelic_rpm-9.4.0 lib/new_relic/agent/memory_logger.rb
newrelic_rpm-9.3.1 lib/new_relic/agent/memory_logger.rb
newrelic_rpm-9.3.0 lib/new_relic/agent/memory_logger.rb