Class: MotionPrime::Logger
- Inherits:
-
Object
- Object
- MotionPrime::Logger
- Defined in:
- motion-prime/services/logger.rb
Constant Summary collapse
- LOGGER_ERROR_LEVEL =
0
- LOGGER_INFO_LEVEL =
1
- LOGGER_DEBUG_LEVEL =
2
- LOGGER_DEALLOC_LEVEL =
3
Instance Method Summary collapse
- #current_level ⇒ Object
- #dealloc_items ⇒ Object
- #dealloc_message(type, object, *args) ⇒ Object
- #debug(*args) ⇒ Object
- #error(*args) ⇒ Object
- #info(*args) ⇒ Object
-
#initialize ⇒ Logger
constructor
A new instance of Logger.
Constructor Details
Instance Method Details
#current_level ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'motion-prime/services/logger.rb', line 38 def current_level current_level = self.class.level || @default_level case current_level.to_s when 'error' LOGGER_ERROR_LEVEL when 'info' LOGGER_INFO_LEVEL when 'debug' LOGGER_DEBUG_LEVEL when 'dealloc' LOGGER_DEALLOC_LEVEL else 2 end end |
#dealloc_items ⇒ Object
34 35 36 |
# File 'motion-prime/services/logger.rb', line 34 def dealloc_items self.class.dealloc_items || [] end |
#dealloc_message(type, object, *args) ⇒ Object
26 27 28 29 30 31 32 |
# File 'motion-prime/services/logger.rb', line 26 def (type, object, *args) if LOGGER_DEALLOC_LEVEL <= current_level if dealloc_items.include?(type.to_s) pp "Deallocating #{type}", object.object_id, object.to_s, *args end end end |
#debug(*args) ⇒ Object
22 23 24 |
# File 'motion-prime/services/logger.rb', line 22 def debug(*args) pp(*args) if LOGGER_DEBUG_LEVEL <= current_level end |
#error(*args) ⇒ Object
14 15 16 |
# File 'motion-prime/services/logger.rb', line 14 def error(*args) pp(*args) if LOGGER_ERROR_LEVEL <= current_level end |
#info(*args) ⇒ Object
18 19 20 |
# File 'motion-prime/services/logger.rb', line 18 def info(*args) pp(*args) if LOGGER_INFO_LEVEL <= current_level end |