Skip to content

Commit

Permalink
Merge pull request #136 from klobuczek/master
Browse files Browse the repository at this point in the history
added the option to configure an existing logger (e.g. Rails.logger)
  • Loading branch information
maxdemarzi committed Jan 23, 2014
2 parents 8737a75 + 3c9583e commit b3936d8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/neography/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Config

attr_accessor :protocol, :server, :port, :directory,
:cypher_path, :gremlin_path,
:log_file, :log_enabled, :slow_log_threshold,
:log_file, :log_enabled, :logger, :slow_log_threshold,
:max_threads,
:authentication, :username, :password,
:parser, :max_execution_time
Expand All @@ -22,6 +22,7 @@ def to_hash
:gremlin_path => @gremlin_path,
:log_file => @log_file,
:log_enabled => @log_enabled,
:logger => @logger,
:slow_log_threshold => @slow_log_threshold,
:max_threads => @max_threads,
:authentication => @authentication,
Expand Down
3 changes: 2 additions & 1 deletion lib/neography/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def save_local_configuration(config)
@slow_log_threshold = config[:slow_log_threshold]
@max_threads = config[:max_threads]
@parser = config[:parser]
@logger = config[:logger]

@max_execution_time = { 'max-execution-time' => config[:max_execution_time] }
@user_agent = { "User-Agent" => USER_AGENT }
Expand All @@ -104,7 +105,7 @@ def save_local_configuration(config)
end

if @log_enabled
@logger = Logger.new(@log_file)
@logger ||= Logger.new(@log_file)
end
end

Expand Down
2 changes: 2 additions & 0 deletions spec/unit/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module Neography
its(:gremlin_path) { should == '/ext/GremlinPlugin/graphdb/execute_script' }
its(:log_file) { should == 'neography.log' }
its(:log_enabled) { should == false }
its(:logger) { should == nil }
its(:slow_log_threshold) { should == 0 }
its(:max_threads) { should == 20 }
its(:authentication) { should == nil }
Expand All @@ -33,6 +34,7 @@ module Neography
:gremlin_path => '/ext/GremlinPlugin/graphdb/execute_script',
:log_file => 'neography.log',
:log_enabled => false,
:logger => nil,
:slow_log_threshold => 0,
:max_threads => 20,
:authentication => nil,
Expand Down

0 comments on commit b3936d8

Please sign in to comment.