Implement debug mode
This commit is contained in:
parent
69d885b282
commit
464b75841b
5
features/cli/debug.feature
Normal file
5
features/cli/debug.feature
Normal file
@ -0,0 +1,5 @@
|
||||
Feature: debug CLI option
|
||||
|
||||
Scenario: raises the logger level to DEBUG
|
||||
When I run uhwm with option -d
|
||||
Then the current output must match /log.+debug.+level/i
|
@ -3,6 +3,7 @@ module Uh
|
||||
class Env
|
||||
LOGGER_LEVEL = Logger::WARN
|
||||
LOGGER_LEVEL_VERBOSE = Logger::INFO
|
||||
LOGGER_LEVEL_DEBUG = Logger::DEBUG
|
||||
LOGGER_LEVEL_STRINGS = %w[DEBUG INFO WARN ERROR FATAL UNKNOWN]
|
||||
|
||||
extend Forwardable
|
||||
@ -26,7 +27,8 @@ module Uh
|
||||
|
||||
def logger
|
||||
@logger ||= Logger.new(@output).tap do |o|
|
||||
o.level = verbose? ? LOGGER_LEVEL_VERBOSE : LOGGER_LEVEL
|
||||
o.level = debug? ? LOGGER_LEVEL_DEBUG :
|
||||
verbose? ? LOGGER_LEVEL_VERBOSE : LOGGER_LEVEL
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -61,9 +61,17 @@ module Uh
|
||||
context 'when verbose mode is enabled' do
|
||||
before { env.verbose = true }
|
||||
|
||||
it 'has logger level info set' do
|
||||
expect(env.logger.level).to be Logger::INFO
|
||||
it 'has logger level info set' do
|
||||
expect(env.logger.level).to be Logger::INFO
|
||||
end
|
||||
end
|
||||
|
||||
context 'when debug mode is enabled' do
|
||||
before { env.debug = true }
|
||||
|
||||
it 'has logger level debug set' do
|
||||
expect(env.logger.level).to be Logger::DEBUG
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user