Parent

Class/Module Index [+]

Quicksearch

YARD::Logger

Handles console logging for info, warnings and errors. Uses the stdlib Logger class in Ruby for all the backend logic.

Attributes

show_backtraces[W]

Public Class Methods

instance(pipe = STDERR) click to toggle source

The logger instance @return [Logger] the logger instance

# File lib/yard/logging.rb, line 12
def self.instance(pipe = STDERR)
  @logger ||= new(pipe)
end
new(*args) click to toggle source

Creates a new logger

# File lib/yard/logging.rb, line 17
def initialize(*args)
  super
  self.show_backtraces = true
  self.level = WARN
  self.formatter = method(:format_log)
end

Public Instance Methods

backtrace(exc) click to toggle source

Prints the backtrace exc to the logger as error data.

@param [Array<String>] exc the backtrace list @return [void]

# File lib/yard/logging.rb, line 35
def backtrace(exc)
  return unless show_backtraces
  error "#{exc.class.class_name}: #{exc.message}"
  error "Stack trace:" +
    exc.backtrace[0..5].map {|x| "\n\t#{x}" }.join + "\n"
end
debug(*args) click to toggle source

Changes the debug level to DEBUG if $DEBUG is set and writes a debugging message.

# File lib/yard/logging.rb, line 26
def debug(*args)
  self.level = DEBUG if $DEBUG
  super
end
enter_level(new_level = level, &block) click to toggle source

Sets the logger level for the duration of the block

@example

log.enter_level(Logger::ERROR) do
  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

# File lib/yard/logging.rb, line 64
def enter_level(new_level = level, &block)
  old_level, self.level = level, new_level
  yield
  self.level = old_level
end
show_backtraces() click to toggle source
# File lib/yard/logging.rb, line 8
def show_backtraces; @show_backtraces || level == DEBUG end
warn_no_continuations() click to toggle source

Warns that the Ruby environment does not support continuations. Applies to JRuby, Rubinius and MacRuby. This warning will only display once per Ruby process.

@return [void]

# File lib/yard/logging.rb, line 47
def warn_no_continuations
  return if CONTINUATIONS_SUPPORTED
  return if $NO_CONTINUATION_WARNING
  $NO_CONTINUATION_WARNING = true
  warn "JRuby/MacRuby/Rubinius do not implement Kernel#callcc and cannot " +
       "load files in order. You must specify the correct order manually."
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.