Skip to content

Commit

Permalink
added the option to configure an existing logger (e.g. Rails.logger)
Browse files Browse the repository at this point in the history
  • Loading branch information
klobuczek committed Jan 22, 2014
1 parent 8737a75 commit d0e75a6
Show file tree
Hide file tree
Showing 2 changed files with 4 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

0 comments on commit d0e75a6

Please sign in to comment.