diff --git a/README.md b/README.md index 9ac8cd5..22d0d4e 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ Then, the unpack the binary with: `$> ./unpack this-cert.bin` +The 'thing.rb' supports a "-v" verbose flag. + == Code compiles == To compile the 'unpack' command, just run `make`. diff --git a/thing.rb b/thing.rb index c95cbcf..441dbcf 100644 --- a/thing.rb +++ b/thing.rb @@ -20,7 +20,7 @@ end # local require './huffman' -$log = Logger.new(STDERR) +$log = Logger.new(STDOUT) #$log.level = Logger::DEBUG $log.level = Logger::FATAL @@ -169,7 +169,7 @@ def de_dupe(list, node) if sub_tree.children[key].signature == node.signature sub_tree.children[key].de_duped = true 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 @@ -180,7 +180,7 @@ def de_dupe_driver(tree) before = list.length i = 1 list.each do |node| - puts "de dupe #{i} / #{before}" + $log.info('de_dupe_driver') { "de dupe #{i} / #{before}" } i += 1 de_dupe(list, node) unless node.de_duped end @@ -271,6 +271,10 @@ def build_huffman_for_nodes(parent) end if $0 == __FILE__ + if ARGV.include?("-v") + $log.level = Logger::DEBUG + ARGV.delete("-v") + end if ARGV.length != 2 puts "usage: thing.rb " puts "please specify one of d or c"