Module: D13n::Logger::LogOnce

Included in:
MemoryLogger
Defined in:
lib/d13n/logger/log_once.rb

Constant Summary collapse

NUM_LOG_ONCE_KEYS =
1000

Instance Method Summary collapse

Instance Method Details

#clear_already_loggedObject



19
20
21
# File 'lib/d13n/logger/log_once.rb', line 19

def clear_already_logged
  @already_logged = {}
end

#log_once(level, key, *msgs) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/d13n/logger/log_once.rb', line 7

def log_once(level, key, *msgs)
  return if @already_logged.include?(key)

  if @already_logged.size >= NUM_LOG_ONCE_KEYS && key.kind_of?(String)
    return
  end

  @already_logged[key] = true

  self.send(level, *msgs)
end