Class: Heel::Logger

Inherits:
Rack::CommonLogger
  • Object
show all
Defined in:
lib/heel/logger.rb

Overview

wrapper around the rack common logger to open up the file and flush the logs this is invoked with a ‘use’ command in the Builder so a new instance of ‘Logger’ in created with each request, so we do all the heavy lifting in the meta class.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Logger

Returns a new instance of Logger.



33
34
35
# File 'lib/heel/logger.rb', line 33

def initialize(app)
  super(app)
end

Class Method Details

.logObject



18
19
20
21
22
23
24
# File 'lib/heel/logger.rb', line 18

def log
  # the log can get closed if daemonized, the at_exit will close it.
  if @log.closed? then
    @log = File.open(@log_file, "a")
  end
  @log
end

.log_file=(lf) ⇒ Object



26
27
28
29
30
# File 'lib/heel/logger.rb', line 26

def log_file=(lf)
  @log_file = lf
  @log = File.open(@log_file, "a")
  at_exit { @log.close unless @log.closed? }
end

Instance Method Details

#<<(str) ⇒ Object



37
38
39
40
# File 'lib/heel/logger.rb', line 37

def <<(str)
  Heel::Logger.log.write( str )
  Heel::Logger.log.flush
end