lib/dexter/logging.rb in pgdexter-0.3.7 vs lib/dexter/logging.rb in pgdexter-0.3.8
- old
+ new
@@ -1,11 +1,26 @@
module Dexter
module Logging
+ COLOR_CODES = {
+ red: 31,
+ green: 32,
+ yellow: 33,
+ cyan: 36
+ }
+
+ def output
+ $stdout
+ end
+
def log(message = "")
- puts message unless $log_level == "error"
+ output.puts(message) unless $log_level == "error"
end
- def abort(message)
- raise Dexter::Abort, message
+ def colorize(message, color)
+ if output.tty?
+ "\e[#{COLOR_CODES[color]}m#{message}\e[0m"
+ else
+ message
+ end
end
end
end