Skip to content

Commit

Permalink
feat: send padrino logs to a file in the log dir by default
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Mar 8, 2018
1 parent 845a2b8 commit 7408be0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
12 changes: 6 additions & 6 deletions lib/pact_broker/ui.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@

require 'pact_broker/configuration'
# Stop Padrino creating a log file, as it will try to create it in the gems directory
# http://www.padrinorb.com/api/Padrino/Logger.html
unless defined? PADRINO_LOGGER
log_path = File.join(PactBroker.configuration.log_dir, 'ui.log')
PADRINO_LOGGER = {
production: { log_level: :error, stream: :stderr },
staging: { log_level: :error, stream: :stderr },
test: { log_level: :warn, stream: :stdout },
development: { log_level: :warn, stream: :stdout }
production: { log_level: :error, stream: :to_file, log_path: log_path },
staging: { log_level: :error, stream: :to_file, log_path: log_path },
test: { log_level: :warn, stream: :to_file, log_path: log_path },
development: { log_level: :warn, stream: :to_file, log_path: log_path }
}
end

require 'pact_broker/ui/app'

1 change: 0 additions & 1 deletion lib/pact_broker/ui/controllers/error_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module UI
module Controllers
class ErrorTest < Base
include PactBroker::Services
include PactBroker::Logging

get "/" do
raise PactBroker::Error.new("Don't panic. This is a test UI error.")
Expand Down
3 changes: 1 addition & 2 deletions lib/pact_broker/ui/controllers/matrix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ module Controllers
class Matrix < Base

include PactBroker::Services
include PactBroker::Logging

get "/" do
selectors = [OpenStruct.new, OpenStruct.new]
Expand All @@ -35,7 +34,7 @@ class Matrix < Base
end
end
rescue StandardError => e
log_error(e) unless e.is_a?(PactBroker::Error)
Padrino.logger.exception(e) unless e.is_a?(PactBroker::Error)
locals[:errors] = [e.message]
end
haml :'matrix/show', {locals: locals, layout: :'layouts/main'}
Expand Down

0 comments on commit 7408be0

Please sign in to comment.