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
40 41 42 |
# File 'lib/backup/logger.rb', line 40 def level @level end |
#lines ⇒ Object
Returns the value of attribute lines
40 41 42 |
# File 'lib/backup/logger.rb', line 40 def lines @lines end |
#time ⇒ Object
Returns the value of attribute time
40 41 42 |
# File 'lib/backup/logger.rb', line 40 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] message line text
45 46 47 48 |
# File 'lib/backup/logger.rb', line 45 def formatted_lines = time.strftime("%Y/%m/%d %H:%M:%S") lines.map {|line| "[#{ }][#{ level }] #{ line }" } end |
#matches?(ignores) ⇒ Boolean
50 51 52 53 54 55 |
# File 'lib/backup/logger.rb', line 50 def matches?(ignores) text = lines.join("\n") ignores.any? {|obj| obj.is_a?(Regexp) ? text.match(obj) : text.include?(obj) } end |