seperating output for verbosity
This commit is contained in:
parent
d5e899f804
commit
0d71eb9e15
2 changed files with 9 additions and 3 deletions
|
@ -22,6 +22,8 @@ Then, the unpack the binary with:
|
||||||
`$> ./unpack this-cert.bin`
|
`$> ./unpack this-cert.bin`
|
||||||
|
|
||||||
|
|
||||||
|
The 'thing.rb' supports a "-v" verbose flag.
|
||||||
|
|
||||||
== Code compiles ==
|
== Code compiles ==
|
||||||
|
|
||||||
To compile the 'unpack' command, just run `make`.
|
To compile the 'unpack' command, just run `make`.
|
||||||
|
|
10
thing.rb
10
thing.rb
|
@ -20,7 +20,7 @@ end
|
||||||
# local
|
# local
|
||||||
require './huffman'
|
require './huffman'
|
||||||
|
|
||||||
$log = Logger.new(STDERR)
|
$log = Logger.new(STDOUT)
|
||||||
#$log.level = Logger::DEBUG
|
#$log.level = Logger::DEBUG
|
||||||
$log.level = Logger::FATAL
|
$log.level = Logger::FATAL
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ def de_dupe(list, node)
|
||||||
if sub_tree.children[key].signature == node.signature
|
if sub_tree.children[key].signature == node.signature
|
||||||
sub_tree.children[key].de_duped = true
|
sub_tree.children[key].de_duped = true
|
||||||
sub_tree.children[key] = node
|
sub_tree.children[key] = node
|
||||||
puts "Found dupe! " + node.signature unless node.signature == "[]"
|
$log.info("Found dupe!" ) { node.signature unless node.signature == "[]" }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -180,7 +180,7 @@ def de_dupe_driver(tree)
|
||||||
before = list.length
|
before = list.length
|
||||||
i = 1
|
i = 1
|
||||||
list.each do |node|
|
list.each do |node|
|
||||||
puts "de dupe #{i} / #{before}"
|
$log.info('de_dupe_driver') { "de dupe #{i} / #{before}" }
|
||||||
i += 1
|
i += 1
|
||||||
de_dupe(list, node) unless node.de_duped
|
de_dupe(list, node) unless node.de_duped
|
||||||
end
|
end
|
||||||
|
@ -271,6 +271,10 @@ def build_huffman_for_nodes(parent)
|
||||||
end
|
end
|
||||||
|
|
||||||
if $0 == __FILE__
|
if $0 == __FILE__
|
||||||
|
if ARGV.include?("-v")
|
||||||
|
$log.level = Logger::DEBUG
|
||||||
|
ARGV.delete("-v")
|
||||||
|
end
|
||||||
if ARGV.length != 2
|
if ARGV.length != 2
|
||||||
puts "usage: thing.rb <d|c> <file>"
|
puts "usage: thing.rb <d|c> <file>"
|
||||||
puts "please specify one of d or c"
|
puts "please specify one of d or c"
|
||||||
|
|
Loading…
Reference in a new issue