Add a --quiet command-line option

--quiet will suppress all log lines except FATAL.  Conceptually it's
exclusive with --verbose, but this isn't checked - last one wins.
This commit is contained in:
Alex Young
2012-07-12 14:45:55 +01:00
parent 10b46beeea
commit c6a084ce82
3 changed files with 64 additions and 15 deletions

View File

@@ -187,9 +187,22 @@ class FlexNBD
end
def build_debug_opt
if @do_debug
if `#{@bin} serve --help` =~ /--verbose/
"--verbose"
else
""
end
else
"--quiet"
end
end
def initialize(bin, ip, port, rebind_ip = ip, rebind_port = port)
@bin = bin
@debug = (ENV['DEBUG'] && `#{@bin} serve --help` =~ /--verbose/) ? "--verbose" : ""
@do_debug = ENV['DEBUG']
@debug = build_debug_opt
raise "#{bin} not executable" unless File.executable?(bin)
@executor = pick_executor.new
@ctrl = "/tmp/.flexnbd.ctrl.#{Time.now.to_i}.#{rand}"
@@ -202,7 +215,7 @@ class FlexNBD
def debug?
!@debug.empty? || ENV['DEBUG']
!!@do_debug
end
def debug( msg )