lib/yard/logging.rb in yard-0.9.5 vs lib/yard/logging.rb in yard-0.9.6

- old
+ new

@@ -1,5 +1,6 @@ +# frozen_string_literal: true require 'logger' require 'thread' module YARD # Handles console logging for info, warnings and errors. @@ -45,10 +46,11 @@ self.show_progress = false self.level = WARN self.formatter = method(:format_log) @progress_indicator = 0 @mutex = Mutex.new + @progress_msg = nil end # Changes the debug level to DEBUG if $DEBUG is set # and writes a debugging message. def debug(*args) @@ -63,11 +65,11 @@ # @param [String] msg the message to display # @param [Symbol, nil] nontty_log the level to log as if the output # stream is not a TTY. Use +nil+ for no alternate logging. # @yield a block of arbitrary code to benchmark # @return [void] - def capture(msg, nontty_log = :debug, &block) + def capture(msg, nontty_log = :debug) progress(msg, nontty_log) yield ensure clear_progress end @@ -116,22 +118,22 @@ # @since 0.8.2 def puts(msg = '') print("#{msg}\n") end - alias_method :print_no_newline, :<< + alias print_no_newline << private :print_no_newline # Displays an unformatted line to the logger output stream. # @param [String] msg the message to display # @return [void] # @since 0.8.2 def print(msg = '') clear_line print_no_newline(msg) end - alias_method :<<, :print + alias << print # Prints the backtrace +exc+ to the logger as error data. # # @param [Array<String>] exc the backtrace list # @param [Symbol] level_meth the level to log backtrace at @@ -159,12 +161,13 @@ # YARD.parse_string "def x; end" # end # @param [Fixnum] new_level the logger level for the duration of the block. # values can be found in Ruby's Logger class. # @yield the block with the logger temporarily set to +new_level+ - def enter_level(new_level = level, &block) - old_level, self.level = level, new_level + def enter_level(new_level = level) + old_level = level + self.level = new_level yield ensure self.level = old_level end @@ -180,10 +183,10 @@ return unless @progress_msg print_no_newline("\e[2K\r") end # Log format (from Logger implementation). Used by Logger internally - def format_log(sev, time, prog, msg) + def format_log(sev, _time, _prog, msg) "[#{sev.downcase}]: #{msg}\n" end end end