Class: Backup::Logger::Message

Inherits:
Struct
  • Object
show all
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

Instance Method Summary collapse

Instance Attribute Details

#levelObject

Returns the value of attribute level

Returns:

  • (Object)

    the current value of level



37
38
39
# File 'lib/backup/logger.rb', line 37

def level
  @level
end

#linesObject

Returns the value of attribute lines

Returns:

  • (Object)

    the current value of lines



37
38
39
# File 'lib/backup/logger.rb', line 37

def lines
  @lines
end

#timeObject

Returns the value of attribute time

Returns:

  • (Object)

    the current value of time



37
38
39
# File 'lib/backup/logger.rb', line 37

def time
  @time
end

Instance Method Details

#formatted_linesObject

Returns an Array of the message lines in the following format:

[YYYY/MM/DD HH:MM:SS][level] message line text


42
43
44
45
# File 'lib/backup/logger.rb', line 42

def formatted_lines
  timestamp = time.strftime("%Y/%m/%d %H:%M:%S")
  lines.map { |line| "[#{timestamp}][#{level}] #{line}" }
end

#matches?(ignores) ⇒ Boolean

Returns:

  • (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