Class: Translatomatic::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/translatomatic/logger.rb

Overview

Logging

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTranslatomatic::Logger

Returns create a new logger instance.



10
11
12
13
14
15
16
# File 'lib/translatomatic/logger.rb', line 10

def initialize
  @logger = ::Logger.new(STDOUT)
  @logger.level = ENV['DEBUG'] ? ::Logger::DEBUG : ::Logger::INFO
  @logger.formatter = proc do |_severity, _datetime, _progname, msg|
    "#{msg}\n"
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object (private)



32
33
34
35
36
37
38
# File 'lib/translatomatic/logger.rb', line 32

def method_missing(name, *args)
  if @logger.respond_to?(name)
    handle_logger_method(name, args)
  else
    super
  end
end

Instance Attribute Details

#progressbarProgressBar

Returns A progress bar.

Returns:

  • (ProgressBar)

    A progress bar



7
8
9
# File 'lib/translatomatic/logger.rb', line 7

def progressbar
  @progressbar
end

Instance Method Details

#finishObject

Called at the end of translatomatic to clear the progress bar.



19
20
21
22
23
24
# File 'lib/translatomatic/logger.rb', line 19

def finish
  @finished ||= begin
    @progressbar.finish if @progressbar
    true
  end
end