Skip to content

Commit

Permalink
Merge pull request #119 from dbyron0/pass_logger_to_serverengine
Browse files Browse the repository at this point in the history
Give serverengine the same logger object sneakers uses.  Avoid problems ...
  • Loading branch information
jondot committed Apr 24, 2015
2 parents 99e7863 + f90e810 commit 61a3dd3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/sneakers/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,15 @@ def reload_config!
end

private
def make_serverengine_config
def make_serverengine_config
# From Sneakers#setup_general_logger, there's support for a Logger object
# in CONFIG[:log]. However, serverengine takes an object in :logger.
# Pass our logger object so there's no issue about sometimes passing a
# file and sometimes an object.
without_log = Sneakers::CONFIG.merge(@conf)
without_log.delete(:log)
Sneakers::CONFIG.merge(@conf).merge({
:logger => Sneakers.logger,
:worker_type => 'process',
:worker_classes => @worker_classes
})
Expand Down
26 changes: 26 additions & 0 deletions spec/sneakers/runner_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
require 'logger'
require 'spec_helper'
require 'sneakers'

describe Sneakers::Runner do
let(:logger) { Logger.new('logtest.log') }

describe "with configuration that specifies a logger object" do
before do
Sneakers.configure(log: logger)
@runner = Sneakers::Runner.new([])
end

it 'passes the logger to serverengine' do
# Stub out ServerEngine::Daemon.run so we only exercise the way we invoke
# ServerEngine.create
any_instance_of(ServerEngine::Daemon) do |daemon|
stub(daemon).main{ return 0 }
end

@runner.run
# look at @runner's @se instance variable (actually of type Daemon)...and
# figure out what it's logger is...
end
end
end

0 comments on commit 61a3dd3

Please sign in to comment.