Browse files

CHORE: Updated TTYColors for Io-based adapters

  • Loading branch information...
1 parent 61c38d9 commit 590a38ec8ffc71d4d7af11549998ef093b410b37 @rudionrails committed Mar 1, 2013
Showing with 14 additions and 14 deletions.
  1. +4 −4 examples/004.1-colorizing-the-log-output.rb
  2. +10 −10 lib/yell/adapters/io.rb
View
8 examples/004.1-colorizing-the-log-output.rb
@@ -8,16 +8,16 @@
logger = Yell.new STDOUT, :colors => true
-[:debug, :info, :warn, :error, :fatal, :unknown].each do |level|
- logger.send level, level
+Yell::Severities.each do |level|
+ logger.send level.downcase, level
end
EOS
puts "=== actuale example ==="
logger = Yell.new STDOUT, :colors => true
-[:debug, :info, :warn, :error, :fatal, :unknown].each do |level|
- logger.send level, level
+Yell::Severities.each do |level|
+ logger.send level.downcase, level
end
View
20 lib/yell/adapters/io.rb
@@ -7,14 +7,14 @@ class Io < Yell::Adapters::Base
include Yell::Formatter::Helpers
# The possible unix log colors
- Colors = {
- 0 => "\e[32;1m", # green;bold
- # 1 => "\e[0m", # white
- 2 => "\e[33;1m", # yello;bold
- 3 => "\e[31;1m", # red;bold
- 4 => "\e[35;1m", # magenta;bold
- 5 => "\e[36m", # cyan
- -1 => "\e[0m" # NONE
+ TTYColors = {
+ 0 => "\033[1;32m", # green
+ 1 => "\033[0m", # normal
+ 2 => "\033[1;33m", # yellow
+ 3 => "\033[1;31m", # red
+ 4 => "\033[1;35m", # magenta
+ 5 => "\033[1;36m", # cyan
+ -1 => "\033[0m" # normal
}
# Sets the “sync mode” to true or false.
@@ -57,8 +57,8 @@ def write!( event )
message = format.format(event)
# colorize if applicable
- if colors and color = Colors[event.level]
- message = color + message + Colors[-1]
+ if colors and color = TTYColors[event.level]
+ message = color + message + TTYColors[-1]
end
message << "\n" unless message[-1] == ?\n

0 comments on commit 590a38e

Please sign in to comment.