Sha256: 7e3612e564eebafb2680410851beb4b68ed700b81474d537f1258c3fe3a24665
Contents?: true
Size: 1.19 KB
Versions: 5
Compression:
Stored size: 1.19 KB
Contents
require "forwardable" require "logger" module WebDriverManager class Logger extend Forwardable include ::Logger::Severity def_delegators :@logger, :debug, :debug?, :info, :info?, :warn, :warn?, :error, :error?, :fatal, :fatal?, :level def initialize @logger = create_logger($stdout) end def level=(severity) case severity.to_s.downcase when 'debug'.freeze then @logger.level = DEBUG when 'info'.freeze then @logger.level = INFO when 'warn'.freeze then @logger.level = WARN when 'error'.freeze then @logger.level = ERROR else raise ArgumentError, "invalid log level: #{severity}" end end def output=(io) if @logger.respond_to?(:reopen) @logger.reopen(io) else @logger = create_logger(io) end end private def create_logger(output) logger = ::Logger.new(output) logger.progname = 'WebDriver Manager' logger.level = ($DEBUG ? DEBUG : WARN) logger.formatter = proc do |severity, time, progname, msg| "#{time.strftime('%F %T')} #{severity} #{progname} #{msg}\n" end logger end end end
Version data entries
5 entries across 5 versions & 1 rubygems