Class: Appsignal::Utils::IntegrationMemoryLogger Private

Inherits:
Object
  • Object
show all
Defined in:
lib/appsignal/utils/integration_memory_logger.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constant Summary collapse

LEVELS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

{
  Logger::DEBUG => :DEBUG,
  Logger::INFO => :INFO,
  Logger::WARN => :WARN,
  Logger::ERROR => :ERROR,
  Logger::FATAL => :FATAL,
  Logger::UNKNOWN => :UNKNOWN
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#formatterObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



17
18
19
# File 'lib/appsignal/utils/integration_memory_logger.rb', line 17

def formatter
  @formatter
end

#levelObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



17
18
19
# File 'lib/appsignal/utils/integration_memory_logger.rb', line 17

def level
  @level
end

Instance Method Details

#add(severity, message, _progname = nil) ⇒ Object Also known as: log

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



19
20
21
22
# File 'lib/appsignal/utils/integration_memory_logger.rb', line 19

def add(severity, message, _progname = nil)
  message = formatter.call(severity, Time.now, nil, message) if formatter
  messages[severity] << message
end

#clearObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



49
50
51
# File 'lib/appsignal/utils/integration_memory_logger.rb', line 49

def clear
  messages.clear
end

#debug(message) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



25
26
27
# File 'lib/appsignal/utils/integration_memory_logger.rb', line 25

def debug(message)
  add(:DEBUG, message)
end

#error(message) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



37
38
39
# File 'lib/appsignal/utils/integration_memory_logger.rb', line 37

def error(message)
  add(:ERROR, message)
end

#fatal(message) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



41
42
43
# File 'lib/appsignal/utils/integration_memory_logger.rb', line 41

def fatal(message)
  add(:FATAL, message)
end

#info(message) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



29
30
31
# File 'lib/appsignal/utils/integration_memory_logger.rb', line 29

def info(message)
  add(:INFO, message)
end

#messagesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



53
54
55
# File 'lib/appsignal/utils/integration_memory_logger.rb', line 53

def messages
  @messages ||= Hash.new { |hash, key| hash[key] = [] }
end

#messages_for_level(level) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



57
58
59
60
61
62
# File 'lib/appsignal/utils/integration_memory_logger.rb', line 57

def messages_for_level(level)
  levels = LEVELS.select { |log_level| log_level >= level }.values
  messages
    .select { |log_level| levels.include?(log_level) }
    .flat_map { |_level, message| message }
end

#unknown(message) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



45
46
47
# File 'lib/appsignal/utils/integration_memory_logger.rb', line 45

def unknown(message)
  add(:UNKNOWN, message)
end

#warn(message) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



33
34
35
# File 'lib/appsignal/utils/integration_memory_logger.rb', line 33

def warn(message)
  add(:WARN, message)
end