aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2014-04-20 06:57:31 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2014-04-20 06:57:31 -0700
commitc8ce5fa45fde0e2bd1b3e6f1a336d2853b242ff2 (patch)
tree77bf1a44fa623bec27f78dd7b352e06c00211225 /core
parentd439860ebd6915fdd2f52f66cb032106e55c4777 (diff)
downloaddinobot-c8ce5fa45fde0e2bd1b3e6f1a336d2853b242ff2.tar.gz
dinobot-c8ce5fa45fde0e2bd1b3e6f1a336d2853b242ff2.tar.xz
More abstraction in logger; fix bug in IRC gets.
Diffstat (limited to 'core')
-rw-r--r--core/irc.rb1
-rw-r--r--core/logger.rb26
2 files changed, 12 insertions, 15 deletions
diff --git a/core/irc.rb b/core/irc.rb
index 0cde75d..fdb2ad7 100644
--- a/core/irc.rb
+++ b/core/irc.rb
@@ -35,6 +35,7 @@ module Dinobot
def gets
str = @socket.gets
+ str.chomp! unless str.nil?
@logger.in str.inspect
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