Skip to content

Commit 14e1ea2

Browse files
committed
CHANGE: Timeout, added console handler for logging
1 parent 86b05c2 commit 14e1ea2

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

aproxyrelay/__init__.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,19 @@
1414
"""
1515
from asyncio import get_event_loop, gather
1616
from datetime import datetime, UTC
17-
from logging import basicConfig, INFO, DEBUG, getLogger
1817
from typing import Callable
1918
from queue import Queue
2019

20+
import logging
21+
2122
from .core import AProxyRelayCore
2223

2324

2425
class AProxyRelay(AProxyRelayCore):
2526
def __init__(
2627
self,
2728
targets: list[str],
28-
timeout: int = 5,
29+
timeout: int = 30,
2930
scrape: bool = True,
3031
filter: bool = True,
3132
zones: list[str] = ['US'], # noqa: B006
@@ -48,7 +49,7 @@ def __init__(
4849
```py
4950
proxy_relay = AProxyRelay(
5051
targets=targets,
51-
timeout=5,
52+
timeout=30,
5253
scrape=True,
5354
filter=True,
5455
zones=['US', 'DE'],
@@ -58,8 +59,13 @@ def __init__(
5859
```
5960
"""
6061
# Configure the logger
61-
basicConfig(level=INFO if not debug else DEBUG)
62-
self.logger = getLogger(__name__)
62+
logging.basicConfig(level=logging.INFO if not debug else logging.DEBUG)
63+
self.logger = logging.getLogger(__name__)
64+
console_handler = logging.StreamHandler()
65+
console_handler.setLevel(logging.DEBUG if debug else logging.INFO)
66+
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
67+
console_handler.setFormatter(formatter)
68+
self.logger.addHandler(console_handler)
6369

6470
# Initialize Core
6571
AProxyRelayCore.__init__(self)

0 commit comments

Comments
 (0)