Class: RubyRed::Console
- Inherits:
-
Object
- Object
- RubyRed::Console
- Defined in:
- lib/rubyred/console.rb
Constant Summary collapse
- MODES =
The modes this logger can have. This is probably useless unless you want to write your own Logger
{ debug: { long: 'DEBUG', short: 'D', format_code: '' }, good: { long: 'GOOD', short: '✓', format_code: "\u001B[32m" }, # green info: { long: 'INFO', short: 'i', format_code: '' }, warn: { long: 'WARN', short: '!', format_code: "\u001B[33m" }, # yellow error: { long: 'ERROR', short: '✗', format_code: "\u001B[31m" }, # red out: { long: 'OUT', short: '→', format_code: "\u001B[36m" }, # cyan in: { long: 'IN', short: '←', format_code: "\u001B[35m" } # purple }.freeze
- FORMAT_RESET =
The ANSI format code that resets formatting
"\u001B[0m".freeze
- FORMAT_BOLD =
The ANSI format code that makes something bold
"\u001B[1m".freeze
Instance Attribute Summary collapse
-
#fancy ⇒ Object
writeonly
Sets the attribute fancy.
Instance Method Summary collapse
-
#initialize(mode = :normal) ⇒ Console
constructor
A new instance of Console.
-
#log_exception(e) ⇒ Object
Logs an exception to the console.
- #mode=(value) ⇒ Object
Constructor Details
#initialize(mode = :normal) ⇒ Console
Returns a new instance of Console.
7 8 9 10 |
# File 'lib/rubyred/console.rb', line 7 def initialize(mode = :normal) self.mode = mode time = Time.now.strftime(CON_TIMESTAMP_FMT) end |
Instance Attribute Details
#fancy=(value) ⇒ Object (writeonly)
Sets the attribute fancy
5 6 7 |
# File 'lib/rubyred/console.rb', line 5 def fancy=(value) @fancy = value end |
Instance Method Details
#log_exception(e) ⇒ Object
Logs an exception to the console.
49 50 51 52 |
# File 'lib/rubyred/console.rb', line 49 def log_exception(e) error(e.inspect) e.backtrace.each { |line| error(line) } end |
#mode=(value) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/rubyred/console.rb', line 38 def mode=(value) case value when :debug @log_modes = @enabled_modes = [:debug, :good, :info, :warn, :error, :out, :in] when :normal @log_modes = [:warn, :error] @enabled_modes = [:info, :warn, :error] end end |