Skip to content

Commit

Permalink
feat(logger): Replace CommonLogger by Clogger to be able to log with …
Browse files Browse the repository at this point in the history
…combined apache format
  • Loading branch information
paulRbr committed Nov 30, 2014
1 parent 21c4f11 commit 83e87b5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
16 changes: 7 additions & 9 deletions lib/yodatra/logger.rb
@@ -1,3 +1,5 @@
require "clogger"

module Yodatra
class Logger < Sinatra::Base

Expand All @@ -6,16 +8,12 @@ class Logger < Sinatra::Base
set :root, Dir.pwd
end
configure :development, :production do
filename_stdout = File.join(root, 'log', "#{environment}.log")
filename_stderr = File.join(root, 'log', "#{environment}.err.log")
file_stdout = File.new(filename_stdout, 'a+')
file_stderr = File.new(filename_stderr, 'a+')
path ||= File.join(Dir.pwd, 'log', "#{environment}.log")
format ||= :Combined
file_stdout = File.new(path, 'a+')
file_stdout.sync = true
file_stderr.sync = true
use Rack::CommonLogger, file_stdout
$stderr.reopen(file_stderr)
use Clogger, :logger => file_stdout, :format => format
end

end

end
end
3 changes: 2 additions & 1 deletion yodatra.gemspec
Expand Up @@ -17,6 +17,7 @@ Gem::Specification.new 'yodatra', Yodatra::VERSION do |s|
s.add_dependency 'sinatra', '~> 1.4.4', '>= 1.4.4'
s.add_dependency 'sinatra-activerecord', '>= 1.2.4'
s.add_dependency 'sinatra-logger'
s.add_dependency 'clogger'
s.add_dependency 'sinatra-contrib', '~> 1.4.2', '>= 1.4.2'
s.add_dependency 'rack-protection', '~> 1.4'
end
end

0 comments on commit 83e87b5

Please sign in to comment.