mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-04 00:00:37 -04:00
removing usage of global unshareable object in default options
This commit is contained in:
parent
594f6056da
commit
c019f1b3a7
@ -13,11 +13,14 @@ module HTTPX
|
||||
white: 37,
|
||||
}.freeze
|
||||
|
||||
USE_DEBUG_LOG = ENV.key?("HTTPX_DEBUG")
|
||||
|
||||
def log(level: @options.debug_level, color: nil, &msg)
|
||||
return unless @options.debug
|
||||
return unless @options.debug_level >= level
|
||||
|
||||
debug_stream = @options.debug
|
||||
debug_stream = @options.debug || ($stderr if USE_DEBUG_LOG)
|
||||
|
||||
return unless debug_stream
|
||||
|
||||
message = (+"" << msg.call << "\n")
|
||||
message = "\e[#{COLORS[color]}m#{message}\e[0m" if color && debug_stream.respond_to?(:isatty) && debug_stream.isatty
|
||||
@ -25,9 +28,6 @@ module HTTPX
|
||||
end
|
||||
|
||||
def log_exception(ex, level: @options.debug_level, color: nil)
|
||||
return unless @options.debug
|
||||
return unless @options.debug_level >= level
|
||||
|
||||
log(level: level, color: color) { ex.full_message }
|
||||
end
|
||||
end
|
||||
|
@ -29,7 +29,7 @@ module HTTPX
|
||||
|
||||
DEFAULT_OPTIONS = {
|
||||
:max_requests => Float::INFINITY,
|
||||
:debug => ENV.key?("HTTPX_DEBUG") ? STDERR : nil,
|
||||
:debug => nil,
|
||||
:debug_level => (ENV["HTTPX_DEBUG"] || 1).to_i,
|
||||
:ssl => EMPTY_HASH,
|
||||
:http2_settings => { settings_enable_push: 0 }.freeze,
|
||||
|
@ -4,6 +4,8 @@ module HTTPX
|
||||
end
|
||||
|
||||
module Loggable
|
||||
USE_DEBUG_LOGS: bool
|
||||
|
||||
COLORS: Hash[Symbol, Integer]
|
||||
|
||||
def log: (?level: Integer?, ?color: Symbol?) { () -> String } -> void
|
||||
|
@ -136,7 +136,7 @@ module HTTPX
|
||||
|
||||
def do_initialize: (?options options) -> void
|
||||
|
||||
def access_option: (Hash | Object obj, Symbol k, Hash[Symbol, Symbol] ivar_map)
|
||||
def access_option: (Hash | Object | nil obj, Symbol k, Hash[Symbol, Symbol]? ivar_map) -> untyped
|
||||
end
|
||||
|
||||
type options = Options | Hash[Symbol, untyped]
|
||||
|
Loading…
x
Reference in New Issue
Block a user