Skip to content

Commit

Permalink
Merge pull request #223 from MasterLambaster/pull-3
Browse files Browse the repository at this point in the history
Allow to set logger level in initialization
  • Loading branch information
carsomyr committed Jul 26, 2012
2 parents d9b0437 + fc899aa commit 5cec25c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/capistrano/logger.rb
Expand Up @@ -7,7 +7,7 @@ class Logger #:nodoc:
INFO = 1
DEBUG = 2
TRACE = 3

MAX_LEVEL = 3

def initialize(options={})
Expand All @@ -20,7 +20,7 @@ def initialize(options={})
end

@options = options
@level = 0
@level = options[:level] || 0
end

def close
Expand Down
10 changes: 10 additions & 0 deletions test/logger_test.rb
Expand Up @@ -13,6 +13,16 @@ def test_logger_should_use_STDERR_by_default
assert_equal STDERR, logger.device
end

def test_logger_should_have_log_level_0
logger = Capistrano::Logger.new
assert_equal 0, logger.level
end

def test_logger_should_use_level_form_options
logger = Capistrano::Logger.new :level => 4
assert_equal 4, logger.level
end

def test_logger_should_use_output_option_if_output_responds_to_puts
logger = Capistrano::Logger.new(:output => STDOUT)
assert_equal STDOUT, logger.device
Expand Down

0 comments on commit 5cec25c

Please sign in to comment.