Skip to content

Commit

Permalink
Fix logger so that it logs to the log file and not stderr.
Browse files Browse the repository at this point in the history
Fixes #10
  • Loading branch information
copiousfreetime committed Sep 30, 2013
1 parent 47b24d1 commit e893c23
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/heel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module Heel
require 'heel/configuration'
require 'heel/directory_indexer'
require 'heel/error_response'
require 'heel/logger'
require 'heel/mime_map'
require 'heel/rackapp'
require 'heel/request'
Expand Down
14 changes: 14 additions & 0 deletions lib/heel/logger.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module Heel
class Logger
attr_reader :filename
def initialize( filename )
@filename = File.expand_path( filename )
end

def write( msg )
File.open( filename, "ab" ) do |f|
f.write( msg )
end
end
end
end
6 changes: 5 additions & 1 deletion lib/heel/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,11 @@ def launch_browser
def heel_app
app = Heel::RackApp.new({ :document_root => options.document_root,
:highlighting => options.highlighting})

logger = Heel::Logger.new( log_file )

stack = Rack::Builder.new {
use Rack::CommonLogger, logger
map "/" do
run app
end
Expand Down Expand Up @@ -256,7 +260,7 @@ def server_options
:pid => pid_file,
:Port => options.port,
:Host => options.address,
:environment => 'deployment',
:environment => 'none',
:server => 'puma',
:daemonize => options.daemonize
}
Expand Down

0 comments on commit e893c23

Please sign in to comment.