Permalink
Browse files

Allow custom loggers (#768)

* Allow custom loggers
* Simplify logger checking if statement
  • Loading branch information...
binarylogic authored and mereghost committed Jun 2, 2017
1 parent 786ebd2 commit 36d6eabc199e8c07cf93e7f32988e6e5712578ba
Showing with 18 additions and 1 deletion.
  1. +7 −1 lib/hanami/components/components.rb
  2. +11 −0 spec/isolation/components/logger_spec.rb
@@ -28,7 +28,13 @@ module Components # rubocop:disable Metrics/ModuleLength
end
resolve do |configuration|
Hanami::Logger.new(Hanami.environment.project_name, *configuration.logger) unless configuration.logger.nil?
if configuration.logger.is_a?(Array)
if configuration.logger.first.is_a?(::Logger)
configuration.logger.first
else
Hanami::Logger.new(Hanami.environment.project_name, *configuration.logger)
end
end
end
end
@@ -34,4 +34,15 @@
expect(logs.count).to eq(count)
end
end
it "allows custom loggers" do
with_project do
replace 'config/environment.rb', 'logger ', "logger ::Logger.new(STDOUT)"
require Pathname.new(Dir.pwd).join("config", "environment")
Hanami::Components.resolve('logger')
expect(Hanami.logger.class).to eq(::Logger)
end
end
end

0 comments on commit 36d6eab

Please sign in to comment.