Class: YARD::Logger
- Inherits:
-
Logger
- Object
- Logger
- YARD::Logger
- Defined in:
- lib/yard/logging.rb
Overview
Handles console logging for info, warnings and errors. Uses the stdlib Logger class in Ruby for all the backend logic.
Instance Attribute Summary collapse
Class Method Summary collapse
-
.instance(pipe = STDERR) ⇒ Logger
The logger instance.
Instance Method Summary collapse
-
#backtrace(exc) ⇒ void
Prints the backtrace
exc
to the logger as error data. -
#debug(*args) ⇒ Object
Changes the debug level to DEBUG if $DEBUG is set and writes a debugging message.
-
#enter_level(new_level = level) { ... } ⇒ Object
Sets the logger level for the duration of the block.
-
#initialize(*args) ⇒ Logger
constructor
Creates a new logger.
-
#warn_no_continuations ⇒ void
deprecated
Deprecated.
Continuations are no longer needed by YARD 0.8.0+.
Constructor Details
#initialize(*args) ⇒ Logger
Creates a new logger
17 18 19 20 21 22 |
# File 'lib/yard/logging.rb', line 17 def initialize(*args) super self.show_backtraces = true self.level = WARN self.formatter = method(:format_log) end |
Instance Attribute Details
#show_backtraces ⇒ Object
8 |
# File 'lib/yard/logging.rb', line 8 def show_backtraces; @show_backtraces || level == DEBUG end |
Class Method Details
.instance(pipe = STDERR) ⇒ Logger
The logger instance
12 13 14 |
# File 'lib/yard/logging.rb', line 12 def self.instance(pipe = STDERR) @logger ||= new(pipe) end |
Instance Method Details
#backtrace(exc) ⇒ void
This method returns an undefined value.
Prints the backtrace exc
to the logger as error data.
35 36 37 38 39 40 |
# File 'lib/yard/logging.rb', line 35 def backtrace(exc) return unless show_backtraces error "#{exc.class.class_name}: #{exc.}" error "Stack trace:" + exc.backtrace[0..5].map {|x| "\n\t#{x}" }.join + "\n" end |
#debug(*args) ⇒ Object
Changes the debug level to DEBUG if $DEBUG is set and writes a debugging message.
26 27 28 29 |
# File 'lib/yard/logging.rb', line 26 def debug(*args) self.level = DEBUG if $DEBUG super end |
#enter_level(new_level = level) { ... } ⇒ Object
Sets the logger level for the duration of the block
60 61 62 63 64 |
# File 'lib/yard/logging.rb', line 60 def enter_level(new_level = level, &block) old_level, self.level = level, new_level yield self.level = old_level end |
#warn_no_continuations ⇒ void
Continuations are no longer needed by YARD 0.8.0+.
This method returns an undefined value.
Warns that the Ruby environment does not support continuations. Applies to JRuby, Rubinius and MacRuby. This warning will only display once per Ruby process.
48 49 |
# File 'lib/yard/logging.rb', line 48 def warn_no_continuations end |