From c8ce5fa45fde0e2bd1b3e6f1a336d2853b242ff2 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Sun, 20 Apr 2014 06:57:31 -0700 Subject: More abstraction in logger; fix bug in IRC gets. --- core/logger.rb | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'core/logger.rb') diff --git a/core/logger.rb b/core/logger.rb index d73cd15..086967c 100644 --- a/core/logger.rb +++ b/core/logger.rb @@ -5,33 +5,29 @@ module Dinobot @@mutex = Mutex.new def in(*lines) - str = lines.join("\n") - - puts str.gsub(/^/, "\e[32m<<\e[0m ") + pout("\e[32m<<\e[0m ", *lines) end def out(*lines) - str = lines.join("\n") + pout("\e[36m>>\e[0m ", *lines) + end - puts str.gsub(/^/, "\e[36m>>\e[0m ") + def info(*lines) + pout("\e[33m==\e[0m ", *lines) end def error(*lines) - str = lines.join("\n") - - puts str.gsub(/^/, "\e[31m!!\e[0m ") + pout("\e[31m!!\e[0m ", *lines) end - def info(*lines) - str = lines.join("\n") - - puts str.gsub(/^/, "\e[33m==\e[0m ") + def indent(*lines) + pout(' ', *lines) end - def indent(*lines) - str = lines.join("\n") + private - puts str.gsub(/^/, ' ') + def pout(prefix, *lines) + puts lines.join("\n").gsub(/^/, prefix) end class << self -- cgit v1.2.3-70-g09d2