Skip to content

Commit 7408be0

Browse files
committed
feat: send padrino logs to a file in the log dir by default
1 parent 845a2b8 commit 7408be0

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

lib/pact_broker/ui.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
1+
require 'pact_broker/configuration'
22
# Stop Padrino creating a log file, as it will try to create it in the gems directory
33
# http://www.padrinorb.com/api/Padrino/Logger.html
44
unless defined? PADRINO_LOGGER
5+
log_path = File.join(PactBroker.configuration.log_dir, 'ui.log')
56
PADRINO_LOGGER = {
6-
production: { log_level: :error, stream: :stderr },
7-
staging: { log_level: :error, stream: :stderr },
8-
test: { log_level: :warn, stream: :stdout },
9-
development: { log_level: :warn, stream: :stdout }
7+
production: { log_level: :error, stream: :to_file, log_path: log_path },
8+
staging: { log_level: :error, stream: :to_file, log_path: log_path },
9+
test: { log_level: :warn, stream: :to_file, log_path: log_path },
10+
development: { log_level: :warn, stream: :to_file, log_path: log_path }
1011
}
1112
end
1213

1314
require 'pact_broker/ui/app'
14-

lib/pact_broker/ui/controllers/error_test.rb

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ module UI
77
module Controllers
88
class ErrorTest < Base
99
include PactBroker::Services
10-
include PactBroker::Logging
1110

1211
get "/" do
1312
raise PactBroker::Error.new("Don't panic. This is a test UI error.")

lib/pact_broker/ui/controllers/matrix.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ module Controllers
1010
class Matrix < Base
1111

1212
include PactBroker::Services
13-
include PactBroker::Logging
1413

1514
get "/" do
1615
selectors = [OpenStruct.new, OpenStruct.new]
@@ -35,7 +34,7 @@ class Matrix < Base
3534
end
3635
end
3736
rescue StandardError => e
38-
log_error(e) unless e.is_a?(PactBroker::Error)
37+
Padrino.logger.exception(e) unless e.is_a?(PactBroker::Error)
3938
locals[:errors] = [e.message]
4039
end
4140
haml :'matrix/show', {locals: locals, layout: :'layouts/main'}

0 commit comments

Comments
 (0)