From d0e75a6b689318229319d14bfd40e4885cc3f3f3 Mon Sep 17 00:00:00 2001 From: Heinrich Klobuczek Date: Tue, 21 Jan 2014 21:32:00 -0800 Subject: [PATCH] added the option to configure an existing logger (e.g. Rails.logger) --- lib/neography/config.rb | 3 ++- lib/neography/connection.rb | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) 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