diff --git a/lib/neography/config.rb b/lib/neography/config.rb index 7334a9f..86090bb 100644 --- a/lib/neography/config.rb +++ b/lib/neography/config.rb @@ -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 @@ -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, diff --git a/lib/neography/connection.rb b/lib/neography/connection.rb index 6d896a9..2a6289d 100644 --- a/lib/neography/connection.rb +++ b/lib/neography/connection.rb @@ -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 } @@ -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 diff --git a/spec/unit/config_spec.rb b/spec/unit/config_spec.rb index 9e38b54..418f554 100644 --- a/spec/unit/config_spec.rb +++ b/spec/unit/config_spec.rb @@ -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 } @@ -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,