Skip to content

Commit 26d8cb7

Browse files
authored
Allowing log_level to be set during instantiation of RequestProxy (#68) (#67)
* Allowing log_level to be set during instantiation of RequestProxy * Bump version to 1.3.2
1 parent 5abec6d commit 26d8cb7

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,14 @@ To use **http-request-randomizer** as a library, include it in your requirements
9393
Then you can simply generate a proxied request using a method call:
9494

9595
````python
96+
import logging
9697
import time
9798
from http_request_randomizer.requests.proxy.requestProxy import RequestProxy
9899

99100
if __name__ == '__main__':
100101

101102
start = time.time()
102-
req_proxy = RequestProxy()
103+
req_proxy = RequestProxy(log_level=logging.ERROR)
103104
print("Initialization took: {0} sec".format((time.time() - start)))
104105
print("Size: {0}".format(len(req_proxy.get_proxy_list())))
105106
print("ALL = {0} ".format(list(map(lambda x: x.get_address(), req_proxy.get_proxy_list()))))
@@ -118,6 +119,9 @@ if __name__ == '__main__':
118119
time.sleep(10)
119120
````
120121

122+
### Changing log levels
123+
The `RequestProxy` constructor accepts an optional parameter of `log_level` that can be used to change the level of logging. By default, this is equal to 0, or NOTSET. The python logging levels are documented [here](https://docs.python.org/3/library/logging.html#logging-levels). You can either use integers or their equivalent constant in the logging module. (e.g. `logging.DEBUG`, `logging.ERROR`, etc)
124+
121125
## Documentation
122126

123127
[http-request-randomizer documentation](https://pgaref.com/HTTP_Request_Randomizer)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
__author__ = 'pgaref'
22

3-
__version__ = '1.2.3'
3+
__version__ = '1.3.2'
44

55
__title__ = 'http_request_randomizer'
66
__description__ = 'A package using public proxies to randomise http requests'
@@ -10,4 +10,4 @@
1010
__email__ = 'pangaref@gmail.com'
1111

1212
__license__ = 'MIT'
13-
__copyright__ = 'Copyright (c) 2020 ' + __author__
13+
__copyright__ = 'Copyright (c) 2020 ' + __author__

http_request_randomizer/requests/proxy/requestProxy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131

3232

3333
class RequestProxy:
34-
def __init__(self, web_proxy_list=[], sustain=False, timeout=5, protocol=Protocol.HTTP):
34+
def __init__(self, web_proxy_list=[], sustain=False, timeout=5, protocol=Protocol.HTTP, log_level=0):
3535
self.logger = logging.getLogger()
3636
self.logger.addHandler(handler)
37-
self.logger.setLevel(0)
37+
self.logger.setLevel(log_level)
3838
self.userAgent = UserAgentManager(file=os.path.join(os.path.dirname(__file__), '../data/user_agents.txt'))
3939

4040
#####

0 commit comments

Comments
 (0)