Programming Ruby 3.2 (5th Edition): B2.0 page 391, warn or $stderr.puts?


page 391, second to last paragraph : discrepancy warn <-> $stderr.puts

There’s an important subtlety in this code. The body of the log method contains this line:

warn("#{now}-#{id_string}: #{self} (#{msg})")

But the body of the log method in metaprogramming/logging_2.rb contains :

$stderr.puts("#{now}-#{id_string}: #{self} (#{msg})")

That said, the output is the same.

Pretty sure this is a case where I updated the file to match the standard gem, but didn’t realize it was referenced in the text. Thanks!