Class: SimpleLogger
Overview
Copyright 2008-2010 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Instance Attribute Summary collapse
-
#level ⇒ Object
Returns the value of attribute level.
Instance Method Summary collapse
- #error(msg) ⇒ Object
- #fatal(msg) ⇒ Object
- #info(msg) ⇒ Object
-
#initialize ⇒ SimpleLogger
constructor
A new instance of SimpleLogger.
- #puts(msg) ⇒ Object
- #trace(msg) ⇒ Object
Constructor Details
#initialize ⇒ SimpleLogger
Returns a new instance of SimpleLogger.
7 8 9 |
# File 'lib/simple_logger.rb', line 7 def initialize @level = :info end |
Instance Attribute Details
#level ⇒ Object
Returns the value of attribute level.
5 6 7 |
# File 'lib/simple_logger.rb', line 5 def level @level end |
Instance Method Details
#error(msg) ⇒ Object
27 28 29 30 31 |
# File 'lib/simple_logger.rb', line 27 def error(msg) if [:debug, :trace, :info, :error].include?(level) then STDOUT.puts "#{Time.now.utc} ERROR " + msg end end |
#fatal(msg) ⇒ Object
33 34 35 36 37 |
# File 'lib/simple_logger.rb', line 33 def fatal(msg) if [:debug, :trace, :info, :error, :fatal].include?(level) then STDOUT.puts "#{Time.now.utc} FATAL " + msg end end |
#info(msg) ⇒ Object
21 22 23 24 25 |
# File 'lib/simple_logger.rb', line 21 def info(msg) if [:debug, :trace, :info].include?(level) then STDOUT.puts "#{Time.now.utc} INFO " + msg end end |
#puts(msg) ⇒ Object
11 12 13 |
# File 'lib/simple_logger.rb', line 11 def puts(msg) STDOUT.puts msg end |
#trace(msg) ⇒ Object
15 16 17 18 19 |
# File 'lib/simple_logger.rb', line 15 def trace(msg) if [:debug, :trace].include?(level) then STDOUT.puts "#{Time.now.utc} TRACE " + msg end end |