module MultiSync::Logging

Constants

MUTEX

Public Instance Methods

log(message, level = :debug) click to toggle source
# File lib/multi_sync/logging.rb, line 40
def log(message, level = :debug)
  # We're not in verbose mode so disable all non-info logs
  say_status :sync, message
  return if !MultiSync.verbose && level != :info
  MUTEX.synchronize do
    logger.send(level, message)
  end
end
logger() click to toggle source

Retrieves the current MultiSync logger

# File lib/multi_sync/logging.rb, line 9
def logger
  @logger || initialize_logger
end
logger=(new_logger) click to toggle source

Sets the current MultiSync logger

# File lib/multi_sync/logging.rb, line 14
def logger=(new_logger)
  @logger = new_logger ? new_logger : Logger.new('/dev/null')
end
say_status(status, message, log_status = true) click to toggle source
# File lib/multi_sync/logging.rb, line 29
def say_status(status, message, log_status = true)
  return if status_logger.nil?

  if defined?(Thor) && status_logger.is_a?(Thor)
    MUTEX.synchronize do
      status_logger.say_status status, message, log_status
    end
  end
end
status_logger() click to toggle source

Retrieves the current MultiSync status_logger

# File lib/multi_sync/logging.rb, line 19
def status_logger
  @status_logger || initialize_status_logger
end
status_logger=(new_status_logger) click to toggle source

Sets the current MultiSync logger

# File lib/multi_sync/logging.rb, line 24
def status_logger=(new_status_logger)
  @status_logger = new_status_logger ? new_status_logger : nil
end

Private Instance Methods

initialize_logger() click to toggle source
# File lib/multi_sync/logging.rb, line 59
def initialize_logger
  @logger = ::Logger.new(STDOUT)
end
initialize_status_logger() click to toggle source
# File lib/multi_sync/logging.rb, line 63
def initialize_status_logger
  @status_logger = nil
end