From 7f134adccb20abe773234acecf526c9951b418e8 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Sun, 20 Apr 2014 04:23:20 -0700 Subject: Improved namespace and directory structure. --- core/logger.rb | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 core/logger.rb (limited to 'core/logger.rb') diff --git a/core/logger.rb b/core/logger.rb new file mode 100644 index 0000000..d73cd15 --- /dev/null +++ b/core/logger.rb @@ -0,0 +1,50 @@ +module Dinobot + module Core + class Logger + @@instance = nil + @@mutex = Mutex.new + + def in(*lines) + str = lines.join("\n") + + puts str.gsub(/^/, "\e[32m<<\e[0m ") + end + + def out(*lines) + str = lines.join("\n") + + puts str.gsub(/^/, "\e[36m>>\e[0m ") + end + + def error(*lines) + str = lines.join("\n") + + puts str.gsub(/^/, "\e[31m!!\e[0m ") + end + + def info(*lines) + str = lines.join("\n") + + puts str.gsub(/^/, "\e[33m==\e[0m ") + end + + def indent(*lines) + str = lines.join("\n") + + puts str.gsub(/^/, ' ') + end + + class << self + def instance + return @@instance if @@instance + + @@mutex.synchronize do + @@instance ||= new + end + end + end + + private_class_method :allocate, :new + end + end +end -- cgit v1.2.3-70-g09d2