Class: Backup::Logger::Message
- Inherits:
-
Struct
- Object
- Struct
- Backup::Logger::Message
- Defined in:
- lib/backup/logger.rb
Overview
All messages sent to the Logger are stored in Logger.messages and sent to all enabled logger’s #log method as Message objects.
Instance Attribute Summary collapse
-
#level ⇒ Object
Returns the value of attribute level.
-
#lines ⇒ Object
Returns the value of attribute lines.
-
#time ⇒ Object
Returns the value of attribute time.
Instance Method Summary collapse
-
#formatted_lines ⇒ Object
Returns an Array of the message lines in the following format:.
- #matches?(ignores) ⇒ Boolean
Instance Attribute Details
#level ⇒ Object
Returns the value of attribute level
37 38 39 |
# File 'lib/backup/logger.rb', line 37 def level @level end |
#lines ⇒ Object
Returns the value of attribute lines
37 38 39 |
# File 'lib/backup/logger.rb', line 37 def lines @lines end |
#time ⇒ Object
Returns the value of attribute time
37 38 39 |
# File 'lib/backup/logger.rb', line 37 def time @time end |
Instance Method Details
#formatted_lines ⇒ Object
Returns an Array of the message lines in the following format:
[YYYY/MM/DD HH:MM:SS][level] line text
42 43 44 45 |
# File 'lib/backup/logger.rb', line 42 def formatted_lines = time.strftime("%Y/%m/%d %H:%M:%S") lines.map { |line| "[#{timestamp}][#{level}] #{line}" } end |
#matches?(ignores) ⇒ Boolean
47 48 49 50 51 52 |
# File 'lib/backup/logger.rb', line 47 def matches?(ignores) text = lines.join("\n") ignores.any? do |obj| obj.is_a?(Regexp) ? text.match(obj) : text.include?(obj) end end |