Sha256: 09e0f6ca2938449097200913b6712b4f5d4e002d9005e1ae10a56e9391cce223

Contents?: true

Size: 962 Bytes

Versions: 6

Compression:

Stored size: 962 Bytes

Contents

require 'forwardable'
require 'logger'
require 'ap'

module Appium
  module Logger
    #
    # @example Use logger manually
    #   Appium::Logger.debug('This is info message')
    #   Appium::Logger.warn('This is warning message')
    #
    class << self
      extend Forwardable
      def_delegators :logger, :ap, :fatal, :error, :warn, :info, :debug, :level, :level=, :formatter, :formatter=

      [:fatal, :error, :warn, :info, :debug].each do |level|
        define_method("ap_#{level}") { |obj| logger.ap(obj, level) }
      end

      attr_writer :logger

      private

      def logger
        @logger ||= begin
          logger = ::Logger.new($stdout)
          logger.progname = 'ruby_lib'
          logger.level = ::Logger::WARN
          logger.formatter = proc { |_severity, _datetime, _progname, msg| "#{msg}\n" } # do no special formatting
          logger
        end
      end
    end # class << self
  end # module Logger
end # module Appium

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
appium_lib-9.7.5 lib/appium_lib/core/common/logger.rb
appium_lib-9.7.4 lib/appium_lib/core/common/logger.rb
appium_lib-9.7.3 lib/appium_lib/core/common/logger.rb
appium_lib-9.7.2 lib/appium_lib/core/common/logger.rb
appium_lib-9.7.1 lib/appium_lib/core/common/logger.rb
appium_lib-9.7.0 lib/appium_lib/core/common/logger.rb