Class: NewRelic::Agent::MemoryLogger

Inherits:
Object
  • Object
show all
Includes:
LogOnce
Defined in:
lib/new_relic/agent/memory_logger.rb

Direct Known Subclasses

StartupLogger

Constant Summary

Constants included from LogOnce

LogOnce::NUM_LOG_ONCE_KEYS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from LogOnce

#clear_already_logged, #log_once

Constructor Details

#initializeMemoryLogger

Returns a new instance of MemoryLogger.



14
15
16
17
18
19
# File 'lib/new_relic/agent/memory_logger.rb', line 14

def initialize
  @already_logged_lock = Mutex.new
  clear_already_logged

  @messages = []
end

Instance Attribute Details

#levelObject



25
26
27
# File 'lib/new_relic/agent/memory_logger.rb', line 25

def level
  @level
end

#log_formatterObject



25
26
27
# File 'lib/new_relic/agent/memory_logger.rb', line 25

def log_formatter
  @log_formatter
end

#messagesObject



25
26
27
# File 'lib/new_relic/agent/memory_logger.rb', line 25

def messages
  @messages
end

Instance Method Details

#debug(*msgs, &blk) ⇒ Object



43
44
45
# File 'lib/new_relic/agent/memory_logger.rb', line 43

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

#dump(logger) ⇒ Object



51
52
53
54
55
56
# File 'lib/new_relic/agent/memory_logger.rb', line 51

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

#error(*msgs, &blk) ⇒ Object



31
32
33
# File 'lib/new_relic/agent/memory_logger.rb', line 31

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

#fatal(*msgs, &blk) ⇒ Object



27
28
29
# File 'lib/new_relic/agent/memory_logger.rb', line 27

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

#info(*msgs, &blk) ⇒ Object



39
40
41
# File 'lib/new_relic/agent/memory_logger.rb', line 39

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

#is_startup_logger?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/new_relic/agent/memory_logger.rb', line 21

def is_startup_logger?
  true
end

#log_exception(level, e, backtrace_level = level) ⇒ Object



47
48
49
# File 'lib/new_relic/agent/memory_logger.rb', line 47

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

#warn(*msgs, &blk) ⇒ Object



35
36
37
# File 'lib/new_relic/agent/memory_logger.rb', line 35

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