diff --git a/lib/pact_broker/app.rb b/lib/pact_broker/app.rb index 819fc98e2..14a60a964 100644 --- a/lib/pact_broker/app.rb +++ b/lib/pact_broker/app.rb @@ -1,7 +1,7 @@ require 'pact_broker/configuration' require 'pact_broker/db' require 'pact_broker/project_root' -require 'pact_broker/default_formatter' +require 'pact_broker/logging/default_formatter' require 'rack-protection' require 'rack/hal_browser' require 'rack/pact_broker/store_base_url' @@ -62,7 +62,7 @@ def call env def post_configure configure_logger - SuckerPunch.logger = SemanticLogger['SuckerPunch'] + SuckerPunch.logger = configuration.custom_logger || SemanticLogger['SuckerPunch'] configure_database_connection configure_sucker_punch end diff --git a/lib/pact_broker/configuration.rb b/lib/pact_broker/configuration.rb index ca666aa9a..89545646d 100644 --- a/lib/pact_broker/configuration.rb +++ b/lib/pact_broker/configuration.rb @@ -51,7 +51,7 @@ def initialize @authenticate_with_basic_auth = nil @authorize = nil @api_error_reporters = [] - @semantic_logger = SemanticLogger[Configuration] + @semantic_logger = SemanticLogger["root"] end def self.default_configuration diff --git a/lib/pact_broker/default_formatter.rb b/lib/pact_broker/logging/default_formatter.rb similarity index 100% rename from lib/pact_broker/default_formatter.rb rename to lib/pact_broker/logging/default_formatter.rb diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index cb3205b53..5f2d6d565 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -6,6 +6,10 @@ $: << File.expand_path("../../", __FILE__) +require 'semantic_logger' +require 'pact_broker/logging/default_formatter' +SemanticLogger.add_appender(file_name: "log/test.log", formatter: PactBroker::Logging::DefaultFormatter.new) + require 'db' require 'tasks/database' require 'pact_broker/db'