Class: RubyCrystalCodemod::Logger

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

Constant Summary collapse

LEVELS =
{
  silent: 0,
  error: 1,
  warn: 2,
  log: 3,
  debug: 4,
}

Instance Method Summary collapse

Constructor Details

#initialize(level) ⇒ Logger

Returns a new instance of Logger.



11
12
13
# File 'lib/ruby_crystal_codemod/logger.rb', line 11

def initialize(level)
  @level = LEVELS.fetch(level)
end

Instance Method Details

#debug(*args) ⇒ Object



15
16
17
# File 'lib/ruby_crystal_codemod/logger.rb', line 15

def debug(*args)
  $stdout.puts(*args) if should_output?(:debug)
end

#error(*args) ⇒ Object



27
28
29
# File 'lib/ruby_crystal_codemod/logger.rb', line 27

def error(*args)
  $stderr.puts(*args) if should_output?(:error)
end

#log(*args) ⇒ Object



19
20
21
# File 'lib/ruby_crystal_codemod/logger.rb', line 19

def log(*args)
  $stdout.puts(*args) if should_output?(:log)
end

#warn(*args) ⇒ Object



23
24
25
# File 'lib/ruby_crystal_codemod/logger.rb', line 23

def warn(*args)
  $stderr.puts(*args) if should_output?(:warn)
end