Class: Prefab::InternalLogger

Inherits:
SemanticLogger::Logger
  • Object
show all
Defined in:
lib/prefab/internal_logger.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ InternalLogger

Returns a new instance of InternalLogger.



4
5
6
7
8
# File 'lib/prefab/internal_logger.rb', line 4

def initialize(klass)
  default_level = ENV['PREFAB_LOG_CLIENT_BOOTSTRAP_LOG_LEVEL'] ? ENV['PREFAB_LOG_CLIENT_BOOTSTRAP_LOG_LEVEL'].downcase.to_sym : :warn
  super(klass, default_level)
  instances << self
end

Class Method Details

.using_prefab_log_filter!Object

Our client outputs debug logging, but if you aren’t using Prefab logging this could be too chatty. If you aren’t using prefab log filter, only log warn level and above



27
28
29
30
31
# File 'lib/prefab/internal_logger.rb', line 27

def self.using_prefab_log_filter!
  @@instances.each do |l|
    l.level = :trace
  end
end

Instance Method Details

#local_log_idObject



20
21
22
# File 'lib/prefab/internal_logger.rb', line 20

def local_log_id
  Thread.current.__id__
end

#log(log, message = nil, progname = nil, &block) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/prefab/internal_logger.rb', line 10

def log(log, message = nil, progname = nil, &block)
  return if recurse_check[local_log_id]
  recurse_check[local_log_id] = true
  begin
    super(log, message, progname, &block)
  ensure
    recurse_check[local_log_id] = false
  end
end