From 7f0f02a997413940a2b22ff206b0d369b3a30c14 Mon Sep 17 00:00:00 2001 From: Marrub Date: Sun, 6 Aug 2017 19:27:36 -0400 Subject: [PATCH] Add debug logging verbosity --- source/common.rb | 11 ++++++----- source/main.rb | 2 ++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/source/common.rb b/source/common.rb index 6ad044b..ce39f63 100644 --- a/source/common.rb +++ b/source/common.rb @@ -1,13 +1,14 @@ module Vrobot4 Version = '4.00'.freeze - @@debug = false - def self.debug= set; @@debug = !!set; end - def self.debug ; @@debug; end + @@debug = 0 + def self.debug= set; @@debug = set; end + def self.debug ; @@debug; end def self.log lv, *text - if lv != :DEBUG || @@debug - puts "[" + lv.to_s.center(8) + "] " + text.join(" ") + if (lv != :DEBUG || @@debug >= 1) && + (lv != :DEBUGV || @@debug >= 2) + puts "[" + lv.to_s.ljust(6) + "] " + text.join(" ") end end end diff --git a/source/main.rb b/source/main.rb index 26bab13..c1ad0e8 100644 --- a/source/main.rb +++ b/source/main.rb @@ -34,6 +34,8 @@ module Vrobot4 begin; cfg = YAML.load IO.read(cfgname) rescue; log :ERROR, "error reading bot config:", $!; exit; end + Vrobot4.debug = cfg["debug"] if cfg.has_key? "debug" + begin bots = [] thrds = []