Class/Module Index [+]

Quicksearch

Backup::Logger

Attributes

quiet[RW]

Public Class Methods

clear!() click to toggle source
# File lib/backup/logger.rb, line 57
def clear!
  messages.clear
  @has_warnings = false
end
error(string) click to toggle source

Outputs an error to the console and writes it to the backup.log Called when an Exception has caused the backup process to abort.

# File lib/backup/logger.rb, line 18
def error(string)
  to_console  loggify(string, :error,   :red), true
  to_file     loggify(string, :error)
end
has_warnings?() click to toggle source

Returns true if any warnings have been issued

# File lib/backup/logger.rb, line 53
def has_warnings?
  @has_warnings ||= false
end
message(string) click to toggle source

Outputs a messages to the console and writes it to the backup.log

# File lib/backup/logger.rb, line 10
def message(string)
  to_console  loggify(string, :message, :green)
  to_file     loggify(string, :message)
end
messages() click to toggle source

Returns an Array of all messages written to the log file for this session

# File lib/backup/logger.rb, line 47
def messages
  @messages ||= []
end
normal(string) click to toggle source

Outputs the data as if it were a regular 'puts' command, but also logs it to the backup.log

# File lib/backup/logger.rb, line 34
def normal(string)
  to_console  loggify(string)
  to_file     loggify(string)
end
silent(string) click to toggle source

Silently logs data to the log file

# File lib/backup/logger.rb, line 41
def silent(string)
  to_file     loggify(string, :silent)
end
truncate!(max_bytes = 500_000) click to toggle source
# File lib/backup/logger.rb, line 62
def truncate!(max_bytes = 500_000)
  log_file = File.join(Config.log_path, 'backup.log')
  return unless File.exist?(log_file)

  if File.stat(log_file).size > max_bytes
    FileUtils.mv(log_file, log_file + '~')
    File.open(log_file + '~', 'r') do |io_in|
      File.open(log_file, 'w') do |io_out|
        io_in.seek(-max_bytes, IO::SEEK_END) && io_in.gets
        while line = io_in.gets
          io_out.puts line
        end
      end
    end
    FileUtils.rm_f(log_file + '~')
  end
end
warn(string) click to toggle source

Outputs a notice to the console and writes it to the backup.log Sets has_warnings? true so :on_warning notifications will be sent

# File lib/backup/logger.rb, line 26
def warn(string)
  @has_warnings = true
  to_console  loggify(string, :warning, :yellow), true
  to_file     loggify(string, :warning)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.