Class: Yell::Adapters::Io
Constant Summary collapse
- Colors =
The possible unix log colors
{ 'DEBUG' => "\e[32;1m", # green;bold # 'INFO' => "\e[0m", # white 'WARN' => "\e[33;1m", # yello;bold 'ERROR' => "\e[31;1m", # red;bold 'FATAL' => "\e[35;1m", # magenta;bold 'UNKNOWN' => "\e[36m", # cyan 'DEFAULT' => "\e[0m" # NONE }
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#close ⇒ Object
Close the io stream.
-
#colorize(color = true) ⇒ Object
Enable colorizing the log output.
-
#format(pattern, date_pattern = nil) ⇒ Object
Set the format for your message.
-
#initialize(options = {}, &block) ⇒ Io
constructor
A new instance of Io.
-
#stream ⇒ Object
The IO stream.
Methods inherited from Base
Constructor Details
#initialize(options = {}, &block) ⇒ Io
Returns a new instance of Io.
20 21 22 23 24 25 |
# File 'lib/yell/adapters/io.rb', line 20 def initialize( = {}, &block ) format [:format] colorize .fetch(:colorize, false) super end |
Instance Method Details
#close ⇒ Object
Close the io stream
36 37 38 39 40 |
# File 'lib/yell/adapters/io.rb', line 36 def close @stream.close if @stream.respond_to? :close @stream = nil end |
#colorize(color = true) ⇒ Object
Enable colorizing the log output.
52 53 54 |
# File 'lib/yell/adapters/io.rb', line 52 def colorize( color = true ) @colorize = color end |
#format(pattern, date_pattern = nil) ⇒ Object
Set the format for your message.
43 44 45 46 47 48 49 |
# File 'lib/yell/adapters/io.rb', line 43 def format( pattern, date_pattern = nil ) @formatter = case pattern when Yell::Formatter then pattern when false then Yell::Formatter.new( "%m" ) else Yell::Formatter.new( pattern, date_pattern ) end end |
#stream ⇒ Object
The IO stream
Adapter classes should provide their own implementation of this method.
31 32 33 |
# File 'lib/yell/adapters/io.rb', line 31 def stream raise 'Not implemented' end |