Class: UnitF::Logging::Logger
- Inherits:
-
Object
- Object
- UnitF::Logging::Logger
- Defined in:
- lib/unitf/logging/logger.rb
Instance Method Summary collapse
- #add_writer(writer) ⇒ Object
- #console ⇒ Object
- #debug(message) ⇒ Object
- #dump ⇒ Object
- #error(message) ⇒ Object
- #fatal(message) ⇒ Object
- #info(message) ⇒ Object
-
#initialize ⇒ Logger
constructor
A new instance of Logger.
- #level=(new_level) ⇒ Object
- #warn(message) ⇒ Object
- #write(severity, message) ⇒ Object
Constructor Details
Instance Method Details
#add_writer(writer) ⇒ Object
18 19 20 21 |
# File 'lib/unitf/logging/logger.rb', line 18 def add_writer(writer) @writers << writer writer.level = @level end |
#console ⇒ Object
53 54 55 56 57 58 |
# File 'lib/unitf/logging/logger.rb', line 53 def console @writers.each do |writer| return writer if writer.is_a?(UnitF::Logging::ConsoleWriter) end nil end |
#debug(message) ⇒ Object
23 24 25 |
# File 'lib/unitf/logging/logger.rb', line 23 def debug() write(DEBUG, ) end |
#dump ⇒ Object
60 61 62 63 64 |
# File 'lib/unitf/logging/logger.rb', line 60 def dump @writers.each do |writer| puts "Name: #{writer.name} Type: #{writer.class}" end end |
#error(message) ⇒ Object
35 36 37 |
# File 'lib/unitf/logging/logger.rb', line 35 def error() write(ERROR, ) end |
#fatal(message) ⇒ Object
39 40 41 |
# File 'lib/unitf/logging/logger.rb', line 39 def fatal() write(FATAL, ) end |
#info(message) ⇒ Object
27 28 29 |
# File 'lib/unitf/logging/logger.rb', line 27 def info() write(INFO, ) end |
#level=(new_level) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/unitf/logging/logger.rb', line 43 def level=(new_level) new_level = UnitF::Logging.const_get(new_level.upcase) if new_level.is_a?(String) @level = new_level @writers.each do |writer| writer.level = @level end rescue ArgumentError, NameError self.level = INFO end |
#warn(message) ⇒ Object
31 32 33 |
# File 'lib/unitf/logging/logger.rb', line 31 def warn() write(WARN, ) end |
#write(severity, message) ⇒ Object
66 67 68 69 70 |
# File 'lib/unitf/logging/logger.rb', line 66 def write(severity, ) @writers.each do |writer| writer.log(severity, ) end end |