Class: Translatomatic::Logger
- Inherits:
-
Object
- Object
- Translatomatic::Logger
- Defined in:
- lib/translatomatic/logger.rb
Overview
Logging
Instance Attribute Summary collapse
-
#progressbar ⇒ ProgressBar
A progress bar.
Instance Method Summary collapse
-
#finish ⇒ Object
Called at the end of translatomatic to clear the progress bar.
-
#initialize ⇒ Translatomatic::Logger
constructor
Create a new logger instance.
Constructor Details
#initialize ⇒ Translatomatic::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
#progressbar ⇒ ProgressBar
Returns A progress bar.
7 8 9 |
# File 'lib/translatomatic/logger.rb', line 7 def @progressbar end |
Instance Method Details
#finish ⇒ Object
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 |