Class: Kramdown::PlantUml::LogWrapper
- Defined in:
- lib/kramdown-plantuml/log_wrapper.rb
Overview
Logs stuff
Class Method Summary collapse
Instance Method Summary collapse
- #debug(message) ⇒ Object
- #debug? ⇒ Boolean
- #debug_multiline(multiline_string) ⇒ Object
- #error(message) ⇒ Object
- #info(message) ⇒ Object
-
#initialize(logger) ⇒ LogWrapper
constructor
A new instance of LogWrapper.
- #level ⇒ Object
- #warn(message) ⇒ Object
Constructor Details
#initialize(logger) ⇒ LogWrapper
Returns a new instance of LogWrapper.
10 11 12 13 14 15 16 17 18 |
# File 'lib/kramdown-plantuml/log_wrapper.rb', line 10 def initialize(logger) raise ArgumentError, 'logger cannot be nil' if logger.nil? raise ArgumentError, 'logger must respond to #debug' unless logger.respond_to? :debug raise ArgumentError, 'logger must respond to #info' unless logger.respond_to? :info raise ArgumentError, 'logger must respond to #warn' unless logger.respond_to? :warn raise ArgumentError, 'logger must respond to #error' unless logger.respond_to? :error @logger = logger end |
Class Method Details
.init ⇒ Object
54 55 56 57 58 |
# File 'lib/kramdown-plantuml/log_wrapper.rb', line 54 def init inner = JekyllProvider.jekyll ? JekyllProvider.jekyll.logger : nil inner ||= ConsoleLogger.new(level) new inner end |
.level ⇒ Object
60 61 62 |
# File 'lib/kramdown-plantuml/log_wrapper.rb', line 60 def level @level ||= level_from_env end |
Instance Method Details
#debug(message) ⇒ Object
20 21 22 |
# File 'lib/kramdown-plantuml/log_wrapper.rb', line 20 def debug() write :debug, end |
#debug? ⇒ Boolean
45 46 47 |
# File 'lib/kramdown-plantuml/log_wrapper.rb', line 45 def debug? self.class.level == :debug end |
#debug_multiline(multiline_string) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/kramdown-plantuml/log_wrapper.rb', line 24 def debug_multiline(multiline_string) return if multiline_string.nil? || multiline_string.empty? lines = multiline_string.lines lines.each do |line| write :debug, line.rstrip end end |
#error(message) ⇒ Object
41 42 43 |
# File 'lib/kramdown-plantuml/log_wrapper.rb', line 41 def error() write :error, end |
#info(message) ⇒ Object
33 34 35 |
# File 'lib/kramdown-plantuml/log_wrapper.rb', line 33 def info() write :info, end |
#level ⇒ Object
49 50 51 |
# File 'lib/kramdown-plantuml/log_wrapper.rb', line 49 def level @level ||= level_from_logger || self.class.env end |
#warn(message) ⇒ Object
37 38 39 |
# File 'lib/kramdown-plantuml/log_wrapper.rb', line 37 def warn() write :warn, end |