class Morpheus::Logging::DarkPrinter
An IO class for printing debugging info This is used as a proxy for ::RestClient.log printing right now.
Attributes
String
-
ansi color code for output. Default is dark
- IO
-
to write to
Public Class Methods
Source
# File lib/morpheus/logging.rb, line 133 def self.<<(*messages) instance.<<(*messages) end
Source
# File lib/morpheus/logging.rb, line 121 def self.instance @instance ||= self.new(STDOUT, nil, true) end
DarkPrinter
with io STDOUT
Source
# File lib/morpheus/logging.rb, line 137 def initialize(io, color=nil, is_dark=true) @io = io # || $stdout @color = color # || cyan @is_dark = is_dark end
Source
# File lib/morpheus/logging.rb, line 125 def self.print(*messages) instance.print(*messages) end
Source
# File lib/morpheus/logging.rb, line 129 def self.puts(*messages) instance.puts(*messages) end
Public Instance Methods
Source
# File lib/morpheus/logging.rb, line 179 def <<(*messages) print(*messages) end
Source
# File lib/morpheus/logging.rb, line 159 def print(*messages) if @io print_with_color do messages.flatten.each do |msg| @io.print scrub_message(msg) end end end end
Source
# File lib/morpheus/logging.rb, line 147 def print_with_color(&block) if Term::ANSIColor.coloring? @io.print Term::ANSIColor.reset @io.print @color if @color @io.print Term::ANSIColor.dark if @is_dark end yield if Term::ANSIColor.coloring? @io.print Term::ANSIColor.reset end end
Source
# File lib/morpheus/logging.rb, line 169 def puts(*messages) if @io print_with_color do messages.flatten.each do |msg| @io.puts scrub_message(msg) end end end end
Source
# File lib/morpheus/logging.rb, line 143 def scrub_message(msg) Morpheus::Logging.scrub_message(msg) end