-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: support sniffer block usage #35
Conversation
Sorry, for the misconception. Sniffer.config do |c|
c.logger = Logger.new($stdout)
end And I want to capture requests in two different blocks of code: sniffer1 = Sniffer.new(logger: Logger.new('foo.log'), enabled: true) # it merges with default config
# some code
sniffer1.disable!
# another code
sniffer2 = Sniffer.capture(logger: Logger.new('bar.log') do #sniffer2 enabled
# some requests
end #sniffer2 disabled Yes, I think we have to support nesting (it's a challenge). It writes the request to both sniffer instances: sniffer1 = Sniffer.new(logger: Logger.new('foo.log'), enabled: true)
# requests log into sniffer1
sniffer2 = Sniffer.capture(logger: Logger.new('bar.log') do #sniffer2 enabled
# requests log into both sniffers
end
# requests log into sniffer1
sniffer1.disable! |
b41f899
to
fb5b5c6
Compare
Hi, please take a look, PR is still in WIP (ugly code somwhere, lack of the tests), but want to discuss the idea
So i made:
In usual case works like was before |
One thing I missed, it that we don't want to have default sniffer (without creating at least one instance - the sniffer should not work) |
Made some changes:
capture = Sniffer.new
puts capture.data
capture = Sniffer.new(enabled: true)
capture = Sniffer.capture(enabled: true) do
# make http requests
# supports for nesting
nested = Sniffer.capture(enabled: true, logger: HipsterLogger.new) do
# capture to this, outer, and to default (according to enable settings)
end
end Wait for your review @aderyabin |
…tom with sniffing into every
451a41a
to
f316587
Compare
@aderyabin , could you please review |
Gemfile
Outdated
@@ -2,5 +2,6 @@ source "https://rubygems.org" | |||
|
|||
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } | |||
|
|||
gem 'anyway_config', github: 'palkan/anyway_config' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already defined in gemspec file
[WIP] for #27
Hi!
May be i did not get the idea properly, so i have some questions: