summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jirutka <jakub@jirutka.cz>2018-05-09 16:29:22 +0200
committerJakub Jirutka <jakub@jirutka.cz>2018-05-09 16:29:22 +0200
commit3225740a88aaeeddda4946055e662346e80ac916 (patch)
tree8404b4a94402b6e4056b22c417b189d698734350
parentd667d713295a678e38eb1b0e3be5914be1810667 (diff)
Use Asciidoctor::LoggerManager to obtain default logger if available
-rw-r--r--lib/asciidoctor/interdoc_reftext/resolver.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/asciidoctor/interdoc_reftext/resolver.rb b/lib/asciidoctor/interdoc_reftext/resolver.rb
index 7deac2f..0da8511 100644
--- a/lib/asciidoctor/interdoc_reftext/resolver.rb
+++ b/lib/asciidoctor/interdoc_reftext/resolver.rb
@@ -9,13 +9,21 @@ module Asciidoctor::InterdocReftext
# @param document [Asciidoctor::Document] the document associated with this resolver.
# @param asciidoc_exts [Array<String>] AsciiDoc file extensions (e.g. `.adoc`).
- # @param logger [Logger] the logger to use for logging warning and errors.
+ # @param logger [Logger, nil] the logger to use for logging warning and errors.
+ # Defaults to `Asciidoctor::LoggerManager.logger` if using Asciidoctor 1.5.7+,
+ # or `Logger.new(STDERR)` otherwise.
# @param raise_exceptions [Boolean] whether to raise exceptions, or just log them.
def initialize(document,
asciidoc_exts: ['.adoc', '.asciidoc', '.ad'],
- logger: ::Logger.new(STDERR),
+ logger: nil,
raise_exceptions: true)
+ logger ||= if defined? ::Asciidoctor::LoggerManager
+ ::Asciidoctor::LoggerManager.logger
+ else
+ ::Logger.new(STDERR)
+ end
+
@document = document
@asciidoc_exts = asciidoc_exts.dup.freeze
@logger = logger