Skip to the content.

warn.rb(logger)

Ref. https://docs.ruby-lang.org/ja/latest/library/logger.html

Execution:

require 'logger'
#=> true

logger = Logger.new(STDOUT)
#=> 
#<Logger:0x00007f0759ee8178


puts "Level WARN"
Level WARN
#=> nil
logger.level = Logger::WARN # <= change level
#=> 2

logger.warn("Nothing to do!") # output
W, [2024-12-08T04:08:16.483052 #2495]  WARN -- : Nothing to do!
#=> true
logger.info("Program started") # none
#=> true
logger.debug("Created logger") # none
#=> true

Executed with Ruby 3.3.6