Class: Kraaken::Logger

Inherits:
ActiveSupport::Logger
  • Object
show all
Defined in:
lib/kraaken/logger.rb

Defined Under Namespace

Classes: Color, Formatter, LogDevice

Instance Method Summary collapse

Constructor Details

#initializeLogger

Returns a new instance of Logger.



6
7
8
9
10
# File 'lib/kraaken/logger.rb', line 6

def initialize
  super Kraaken::Logger::LogDevice.new(-> { @progress_bar })
  @painter = Kraaken::Logger::Color.new
  self.formatter = Kraaken::Logger::Formatter.new(@painter)
end

Instance Method Details

#increment_progress(by: 1) ⇒ Object



25
26
27
# File 'lib/kraaken/logger.rb', line 25

def increment_progress(by: 1)
  @progress_bar&.progress += by
end

#with_progress(total:, title: nil, &block) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/kraaken/logger.rb', line 12

def with_progress(total:, title: nil, &block)
  @progress_bar = ProgressBar.create(
    total:,
    title:,
    format: "%t |#{color("%B", color: :blue)}|"
  )

  block.call

  @progress_bar.finish
  @progress_bar = nil
end