lib/pdk/logger.rb in pdk-2.7.1 vs lib/pdk/logger.rb in pdk-3.0.0
- old
+ new
@@ -4,19 +4,19 @@
module PDK
class Logger < ::Logger
WRAP_COLUMN_LIMIT = 78
def initialize
- super(STDERR)
+ super($stderr)
@sent_messages = {}
# TODO: Decide on output format.
self.formatter = proc do |severity, _datetime, _progname, msg|
prefix = "pdk (#{severity}): "
if msg.is_a?(Hash)
if msg.fetch(:wrap, false)
- wrap_pattern = %r{(.{1,#{WRAP_COLUMN_LIMIT - prefix.length}})(\s+|\Z)}
+ wrap_pattern = /(.{1,#{WRAP_COLUMN_LIMIT - prefix.length}})(\s+|\Z)/
"#{prefix}#{msg[:text].gsub(wrap_pattern, "\\1\n#{' ' * prefix.length}")}\n"
else
"#{prefix}#{msg[:text]}\n"
end
else
@@ -28,9 +28,10 @@
end
def warn_once(*args)
hash = args.inspect.hash
return if (@sent_messages[::Logger::WARN] ||= {}).key?(hash)
+
@sent_messages[::Logger::WARN][hash] = true
warn(*args)
end
def enable_debug_output