Sha256: 9afa9125096503c1477a6c4ad16df389dddb21f79663fcb828907ae97c40fbe3

Contents?: true

Size: 953 Bytes

Versions: 7

Compression:

Stored size: 953 Bytes

Contents

# frozen_string_literal: true
require 'logger' unless RUBY_PLATFORM == 'opal'
require 'asciidoctor' unless RUBY_PLATFORM == 'opal'
require 'asciidoctor/html5s/version'

module Asciidoctor::Html5s
  # Helper module for getting default Logger based on the Asciidoctor version.
  module Logging
    module_function

    # @return [Logger] the default `Asciidoctor::Logger` if using Asciidoctor
    #   1.5.7 or later, or Ruby's `Logger` that outputs to `STDERR`.
    def default_logger
      if defined? ::Asciidoctor::LoggerManager
        ::Asciidoctor::LoggerManager.logger
      elsif defined? ::Logger
        ::Logger.new(STDERR)
      else
        # Fake logger for Opal.
        # TODO: Remove after update to Asciidoctor 1.5.7 or Opal with Logger.
        Object.new.tap do |o|
          # rubocop: disable MethodMissing
          def o.method_missing(_, *args)
            STDERR.puts(*args)
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
asciidoctor-html5s-0.1.0 lib/asciidoctor/html5s/logger.rb
asciidoctor-html5s-0.1.0.beta.11 lib/asciidoctor/html5s/logger.rb
asciidoctor-html5s-0.1.0.beta.10 lib/asciidoctor/html5s/logger.rb
asciidoctor-html5s-0.1.0.beta.9 lib/asciidoctor/html5s/logger.rb
asciidoctor-html5s-0.1.0.beta.8 lib/asciidoctor/html5s/logger.rb
asciidoctor-html5s-0.1.0.beta.7 lib/asciidoctor/html5s/logger.rb
asciidoctor-html5s-0.1.0.beta.6 lib/asciidoctor/html5s/logger.rb