Module: Fastr::Log

Included in:
Application, Filter, Plugin, Router, Settings, Test::Application
Defined in:
lib/fastr/logger.rb

Defined Under Namespace

Classes: Formatter

Class Method Summary collapse

Class Method Details

.create_logger(location, level, kls) ⇒ Object



31
32
33
34
35
36
# File 'lib/fastr/logger.rb', line 31

def self.create_logger(location, level, kls)
  logger = Logger.new(location)
  logger.level = level
  logger.formatter = Fastr::Log::Formatter.new(kls)
  logger
end

.included(kls) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fastr/logger.rb', line 9

def self.included(kls)
  level = @log_level
  log_classes = @log_classes
  log_location = @log_location
  
  kls.instance_eval do
    @logger = Fastr::Log.create_logger(log_location, level, kls)
    
    log_classes << @logger
    
    def logger
      @logger
    end
  end
  
  kls.class_eval do
    def log
      self.class.logger
    end
  end
end

.level=(level) ⇒ Object



38
39
40
41
42
43
# File 'lib/fastr/logger.rb', line 38

def self.level=(level)      
  @log_level = level
  @log_classes.each do |log|
    log.level = level
  end
end