Module: I18n::Tasks::Logging

Constant Summary collapse

MUTEX =
Mutex.new
PROGRAM_NAME =
File.basename($PROGRAM_NAME)

Class Method Summary collapse

Class Method Details

.log_error(message) ⇒ Object



21
22
23
# File 'lib/i18n/tasks/logging.rb', line 21

def log_error(message)
  log_stderr Rainbow("#{program_name}: #{message}").red.bright
end

.log_stderr(*args) ⇒ Object



25
26
27
28
29
30
# File 'lib/i18n/tasks/logging.rb', line 25

def log_stderr(*args)
  # We don't want output from different threads to get intermixed.
  MUTEX.synchronize do
    $stderr.puts(*args)
  end
end

.log_verbose(message = nil) ⇒ Object



13
14
15
# File 'lib/i18n/tasks/logging.rb', line 13

def log_verbose(message = nil)
  log_stderr Rainbow(message || yield).blue.bright if ::I18n::Tasks.verbose?
end

.log_warn(message) ⇒ Object



17
18
19
# File 'lib/i18n/tasks/logging.rb', line 17

def log_warn(message)
  log_stderr Rainbow("#{program_name}: [WARN] #{message}").yellow
end

.program_nameObject



32
33
34
# File 'lib/i18n/tasks/logging.rb', line 32

def program_name
  PROGRAM_NAME
end

.warn_deprecated(message) ⇒ Object



9
10
11
# File 'lib/i18n/tasks/logging.rb', line 9

def warn_deprecated(message)
  log_stderr Rainbow("#{program_name}: [DEPRECATED] #{message}").yellow.bright
end