Skip to content

Commit

Permalink
Merge remote-tracking branch 'rouston/move-logs' into organize
Browse files Browse the repository at this point in the history
  • Loading branch information
mfrost committed May 22, 2012
2 parents e2ea056 + 374de6f commit 3fd29dd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion lib/integrity/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,22 @@ def protected?
@username && @password
end

def log_dir
@log_dir ||= File.dirname(__FILE__) + '/../../' + 'log'

if not File.directory? @log_dir
Dir.mkdir @log_dir, 0775
end

@log_dir
end

def log_file
@log_file ||= log_dir + '/' + @log if @log
end

def logger
@logger ||= Logger.new(@log)
@logger ||= Logger.new(log_file)
end

def database=(uri)
Expand Down
2 changes: 1 addition & 1 deletion test/unit/configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ConfiguratorTest < IntegrityTest

test "logging" do
Integrity.configure { |c| c.log = "test.log" }
assert_equal "test.log", Integrity.config.logger.
assert_equal "./lib/integrity/../../log/test.log", Integrity.config.logger.
instance_variable_get(:@logdev).
instance_variable_get(:@dev).path
end
Expand Down

0 comments on commit 3fd29dd

Please sign in to comment.