Class: MarkdownLoggingProxy::MarkdownLogger
- Inherits:
-
Object
- Object
- MarkdownLoggingProxy::MarkdownLogger
- Defined in:
- lib/markdown_logging_proxy/markdown_logger.rb
Instance Attribute Summary collapse
-
#backtrace ⇒ Object
readonly
Returns the value of attribute backtrace.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#heading_level ⇒ Object
readonly
Returns the value of attribute heading_level.
-
#std_logger ⇒ Object
readonly
Returns the value of attribute std_logger.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(location, backtrace: true) ⇒ MarkdownLogger
constructor
A new instance of MarkdownLogger.
- #inspect_backtrace(ignore = 4) ⇒ Object
- #log(level, heading = 3, msg) ⇒ Object
Constructor Details
#initialize(location, backtrace: true) ⇒ MarkdownLogger
Returns a new instance of MarkdownLogger.
10 11 12 13 14 15 |
# File 'lib/markdown_logging_proxy/markdown_logger.rb', line 10 def initialize(location, backtrace: true) @created_at = Time.now @std_logger = create_logger(location) @heading_level = 1 @backtrace = backtrace end |
Instance Attribute Details
#backtrace ⇒ Object (readonly)
Returns the value of attribute backtrace.
8 9 10 |
# File 'lib/markdown_logging_proxy/markdown_logger.rb', line 8 def backtrace @backtrace end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
8 9 10 |
# File 'lib/markdown_logging_proxy/markdown_logger.rb', line 8 def created_at @created_at end |
#heading_level ⇒ Object (readonly)
Returns the value of attribute heading_level.
8 9 10 |
# File 'lib/markdown_logging_proxy/markdown_logger.rb', line 8 def heading_level @heading_level end |
#std_logger ⇒ Object (readonly)
Returns the value of attribute std_logger.
8 9 10 |
# File 'lib/markdown_logging_proxy/markdown_logger.rb', line 8 def std_logger @std_logger end |
Class Method Details
.build(location, **options) ⇒ Object
3 4 5 6 |
# File 'lib/markdown_logging_proxy/markdown_logger.rb', line 3 def self.build(location, **) return location if location.is_a?(MarkdownLogger) new(location, **) end |
Instance Method Details
#inspect_backtrace(ignore = 4) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/markdown_logging_proxy/markdown_logger.rb', line 22 def inspect_backtrace(ignore = 4) return unless backtrace lines = case backtrace when true then caller(ignore) when Regexp then caller(ignore).grep(backtrace) else [] end <<~MSG.chomp Backtrace: #{lines.map { |l| "* #{l.chop}`" }.join("\n")} MSG end |
#log(level, heading = 3, msg) ⇒ Object
17 18 19 20 |
# File 'lib/markdown_logging_proxy/markdown_logger.rb', line 17 def log(level, heading = 3, msg) @heading_level = heading std_logger.send(level, msg) end |