logtail-python 0.3.3__tar.gz → 0.3.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {logtail_python-0.3.3/logtail_python.egg-info → logtail_python-0.3.4}/PKG-INFO +15 -3
- {logtail_python-0.3.3 → logtail_python-0.3.4}/logtail/__init__.py +1 -1
- {logtail_python-0.3.3 → logtail_python-0.3.4}/logtail/handler.py +3 -1
- {logtail_python-0.3.3 → logtail_python-0.3.4}/logtail/uploader.py +4 -3
- {logtail_python-0.3.3 → logtail_python-0.3.4/logtail_python.egg-info}/PKG-INFO +15 -3
- {logtail_python-0.3.3 → logtail_python-0.3.4}/setup.py +1 -1
- {logtail_python-0.3.3 → logtail_python-0.3.4}/tests/test_flusher.py +2 -1
- {logtail_python-0.3.3 → logtail_python-0.3.4}/tests/test_handler.py +10 -0
- {logtail_python-0.3.3 → logtail_python-0.3.4}/tests/test_uploader.py +5 -2
- {logtail_python-0.3.3 → logtail_python-0.3.4}/LICENSE.md +0 -0
- {logtail_python-0.3.3 → logtail_python-0.3.4}/MANIFEST.in +0 -0
- {logtail_python-0.3.3 → logtail_python-0.3.4}/README.md +0 -0
- {logtail_python-0.3.3 → logtail_python-0.3.4}/logtail/compat.py +0 -0
- {logtail_python-0.3.3 → logtail_python-0.3.4}/logtail/flusher.py +0 -0
- {logtail_python-0.3.3 → logtail_python-0.3.4}/logtail/formatter.py +0 -0
- {logtail_python-0.3.3 → logtail_python-0.3.4}/logtail/frame.py +0 -0
- {logtail_python-0.3.3 → logtail_python-0.3.4}/logtail/helpers.py +0 -0
- {logtail_python-0.3.3 → logtail_python-0.3.4}/logtail_python.egg-info/SOURCES.txt +0 -0
- {logtail_python-0.3.3 → logtail_python-0.3.4}/logtail_python.egg-info/dependency_links.txt +0 -0
- {logtail_python-0.3.3 → logtail_python-0.3.4}/logtail_python.egg-info/requires.txt +0 -0
- {logtail_python-0.3.3 → logtail_python-0.3.4}/logtail_python.egg-info/top_level.txt +0 -0
- {logtail_python-0.3.3 → logtail_python-0.3.4}/requirements.txt +0 -0
- {logtail_python-0.3.3 → logtail_python-0.3.4}/setup.cfg +0 -0
- {logtail_python-0.3.3 → logtail_python-0.3.4}/test-requirements.txt +0 -0
- {logtail_python-0.3.3 → logtail_python-0.3.4}/tests/__init__.py +0 -0
- {logtail_python-0.3.3 → logtail_python-0.3.4}/tests/__pycache__/__init__.cpython-311.pyc +0 -0
- {logtail_python-0.3.3 → logtail_python-0.3.4}/tests/__pycache__/test_flusher.cpython-311.pyc +0 -0
- {logtail_python-0.3.3 → logtail_python-0.3.4}/tests/__pycache__/test_formatter.cpython-311.pyc +0 -0
- {logtail_python-0.3.3 → logtail_python-0.3.4}/tests/__pycache__/test_frame.cpython-311.pyc +0 -0
- {logtail_python-0.3.3 → logtail_python-0.3.4}/tests/__pycache__/test_handler.cpython-311.pyc +0 -0
- {logtail_python-0.3.3 → logtail_python-0.3.4}/tests/__pycache__/test_helpers.cpython-311.pyc +0 -0
- {logtail_python-0.3.3 → logtail_python-0.3.4}/tests/__pycache__/test_uploader.cpython-311.pyc +0 -0
- {logtail_python-0.3.3 → logtail_python-0.3.4}/tests/test_formatter.py +0 -0
- {logtail_python-0.3.3 → logtail_python-0.3.4}/tests/test_frame.py +0 -0
- {logtail_python-0.3.3 → logtail_python-0.3.4}/tests/test_helpers.py +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: logtail-python
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.4
|
|
4
4
|
Summary: Logtail.com client library
|
|
5
5
|
Home-page: https://github.com/logtail/logtail-python
|
|
6
|
-
Download-URL: https://github.com/logtail/logtail-python/tarball/0.3.
|
|
6
|
+
Download-URL: https://github.com/logtail/logtail-python/tarball/0.3.4
|
|
7
7
|
Author: Logtail
|
|
8
8
|
Author-email: hello@logtail.com
|
|
9
9
|
License: ISC
|
|
@@ -23,6 +23,18 @@ Description-Content-Type: text/markdown
|
|
|
23
23
|
License-File: LICENSE.md
|
|
24
24
|
Requires-Dist: requests>=2.18.4
|
|
25
25
|
Requires-Dist: msgpack>=0.5.6
|
|
26
|
+
Dynamic: author
|
|
27
|
+
Dynamic: author-email
|
|
28
|
+
Dynamic: classifier
|
|
29
|
+
Dynamic: description
|
|
30
|
+
Dynamic: description-content-type
|
|
31
|
+
Dynamic: download-url
|
|
32
|
+
Dynamic: home-page
|
|
33
|
+
Dynamic: keywords
|
|
34
|
+
Dynamic: license
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
Dynamic: requires-dist
|
|
37
|
+
Dynamic: summary
|
|
26
38
|
|
|
27
39
|
# [Better Stack](https://betterstack.com/logs) Python client
|
|
28
40
|
|
|
@@ -16,6 +16,7 @@ DEFAULT_CHECK_INTERVAL = 0.1
|
|
|
16
16
|
DEFAULT_RAISE_EXCEPTIONS = False
|
|
17
17
|
DEFAULT_DROP_EXTRA_EVENTS = True
|
|
18
18
|
DEFAULT_INCLUDE_EXTRA_ATTRIBUTES = True
|
|
19
|
+
DEFAULT_TIMEOUT = 30
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
class LogtailHandler(logging.Handler):
|
|
@@ -29,6 +30,7 @@ class LogtailHandler(logging.Handler):
|
|
|
29
30
|
drop_extra_events=DEFAULT_DROP_EXTRA_EVENTS,
|
|
30
31
|
include_extra_attributes=DEFAULT_INCLUDE_EXTRA_ATTRIBUTES,
|
|
31
32
|
context=DEFAULT_CONTEXT,
|
|
33
|
+
timeout=DEFAULT_TIMEOUT,
|
|
32
34
|
level=logging.NOTSET):
|
|
33
35
|
super(LogtailHandler, self).__init__(level=level)
|
|
34
36
|
self.source_token = source_token
|
|
@@ -38,7 +40,7 @@ class LogtailHandler(logging.Handler):
|
|
|
38
40
|
self.host = "https://" + host
|
|
39
41
|
self.context = context
|
|
40
42
|
self.pipe = queue.Queue(maxsize=buffer_capacity)
|
|
41
|
-
self.uploader = Uploader(self.source_token, self.host)
|
|
43
|
+
self.uploader = Uploader(self.source_token, self.host, timeout)
|
|
42
44
|
self.drop_extra_events = drop_extra_events
|
|
43
45
|
self.include_extra_attributes = include_extra_attributes
|
|
44
46
|
self.buffer_capacity = buffer_capacity
|
|
@@ -9,9 +9,10 @@ class Fake500(object):
|
|
|
9
9
|
self.exception = exception
|
|
10
10
|
|
|
11
11
|
class Uploader(object):
|
|
12
|
-
def __init__(self, source_token, host):
|
|
12
|
+
def __init__(self, source_token, host, timeout):
|
|
13
13
|
self.source_token = source_token
|
|
14
14
|
self.host = host
|
|
15
|
+
self.timeout = timeout
|
|
15
16
|
self.session = requests.Session()
|
|
16
17
|
self.headers = {
|
|
17
18
|
'Authorization': 'Bearer %s' % source_token,
|
|
@@ -21,6 +22,6 @@ class Uploader(object):
|
|
|
21
22
|
def __call__(self, frame):
|
|
22
23
|
data = msgpack.packb(frame, use_bin_type=True)
|
|
23
24
|
try:
|
|
24
|
-
return self.session.post(self.host, data=data, headers=self.headers)
|
|
25
|
+
return self.session.post(self.host, data=data, headers=self.headers, timeout=self.timeout)
|
|
25
26
|
except requests.RequestException as e:
|
|
26
|
-
return Fake500(e)
|
|
27
|
+
return Fake500(e)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: logtail-python
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.4
|
|
4
4
|
Summary: Logtail.com client library
|
|
5
5
|
Home-page: https://github.com/logtail/logtail-python
|
|
6
|
-
Download-URL: https://github.com/logtail/logtail-python/tarball/0.3.
|
|
6
|
+
Download-URL: https://github.com/logtail/logtail-python/tarball/0.3.4
|
|
7
7
|
Author: Logtail
|
|
8
8
|
Author-email: hello@logtail.com
|
|
9
9
|
License: ISC
|
|
@@ -23,6 +23,18 @@ Description-Content-Type: text/markdown
|
|
|
23
23
|
License-File: LICENSE.md
|
|
24
24
|
Requires-Dist: requests>=2.18.4
|
|
25
25
|
Requires-Dist: msgpack>=0.5.6
|
|
26
|
+
Dynamic: author
|
|
27
|
+
Dynamic: author-email
|
|
28
|
+
Dynamic: classifier
|
|
29
|
+
Dynamic: description
|
|
30
|
+
Dynamic: description-content-type
|
|
31
|
+
Dynamic: download-url
|
|
32
|
+
Dynamic: home-page
|
|
33
|
+
Dynamic: keywords
|
|
34
|
+
Dynamic: license
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
Dynamic: requires-dist
|
|
37
|
+
Dynamic: summary
|
|
26
38
|
|
|
27
39
|
# [Better Stack](https://betterstack.com/logs) Python client
|
|
28
40
|
|
|
@@ -20,10 +20,11 @@ class TestFlushWorker(unittest.TestCase):
|
|
|
20
20
|
buffer_capacity = 5
|
|
21
21
|
flush_interval = 2
|
|
22
22
|
check_interval = 0.01
|
|
23
|
+
timeout = 0.1
|
|
23
24
|
|
|
24
25
|
def _setup_worker(self, uploader=None):
|
|
25
26
|
pipe = queue.Queue(maxsize=self.buffer_capacity)
|
|
26
|
-
uploader = uploader or Uploader(self.source_token, self.host)
|
|
27
|
+
uploader = uploader or Uploader(self.source_token, self.host, self.timeout)
|
|
27
28
|
fw = FlushWorker(uploader, pipe, self.buffer_capacity, self.flush_interval, self.check_interval)
|
|
28
29
|
return pipe, uploader, fw
|
|
29
30
|
|
|
@@ -20,6 +20,16 @@ class TestLogtailHandler(unittest.TestCase):
|
|
|
20
20
|
handler = LogtailHandler(source_token=self.source_token, host=self.host)
|
|
21
21
|
self.assertEqual(handler.uploader.source_token, self.source_token)
|
|
22
22
|
self.assertEqual(handler.uploader.host, "https://" + self.host)
|
|
23
|
+
|
|
24
|
+
@patch('logtail.handler.FlushWorker')
|
|
25
|
+
def test_handler_passes_timeout_to_uploader(self, MockWorker):
|
|
26
|
+
# Test default timeout
|
|
27
|
+
handler = LogtailHandler(source_token=self.source_token, host=self.host)
|
|
28
|
+
self.assertEqual(handler.uploader.timeout, 30)
|
|
29
|
+
|
|
30
|
+
# Test custom timeout
|
|
31
|
+
handler = LogtailHandler(source_token=self.source_token, host=self.host, timeout=10)
|
|
32
|
+
self.assertEqual(handler.uploader.timeout, 10)
|
|
23
33
|
|
|
24
34
|
@patch('logtail.handler.FlushWorker')
|
|
25
35
|
def test_handler_creates_pipe_from_args(self, MockWorker):
|
|
@@ -13,10 +13,11 @@ class TestUploader(unittest.TestCase):
|
|
|
13
13
|
host = 'https://in.logtail.com'
|
|
14
14
|
source_token = 'dummy_source_token'
|
|
15
15
|
frame = [1, 2, 3]
|
|
16
|
+
timeout = 30
|
|
16
17
|
|
|
17
18
|
@patch('logtail.uploader.requests.Session.post')
|
|
18
19
|
def test_call(self, post):
|
|
19
|
-
def mock_post(endpoint, data=None, headers=None):
|
|
20
|
+
def mock_post(endpoint, data=None, headers=None, timeout=None):
|
|
20
21
|
# Check that the data is sent to ther correct endpoint
|
|
21
22
|
self.assertEqual(endpoint, self.host)
|
|
22
23
|
# Check the content-type
|
|
@@ -25,9 +26,11 @@ class TestUploader(unittest.TestCase):
|
|
|
25
26
|
self.assertEqual('application/msgpack', headers.get('Content-Type'))
|
|
26
27
|
# Check the content was msgpacked correctly
|
|
27
28
|
self.assertEqual(msgpack.unpackb(data, raw=False), self.frame)
|
|
29
|
+
# Check that timeout is passed to the request
|
|
30
|
+
self.assertEqual(timeout, 30)
|
|
28
31
|
|
|
29
32
|
post.side_effect = mock_post
|
|
30
|
-
u = Uploader(self.source_token, self.host)
|
|
33
|
+
u = Uploader(self.source_token, self.host, self.timeout)
|
|
31
34
|
u(self.frame)
|
|
32
35
|
|
|
33
36
|
self.assertTrue(post.called)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{logtail_python-0.3.3 → logtail_python-0.3.4}/tests/__pycache__/test_flusher.cpython-311.pyc
RENAMED
|
File without changes
|
{logtail_python-0.3.3 → logtail_python-0.3.4}/tests/__pycache__/test_formatter.cpython-311.pyc
RENAMED
|
File without changes
|
|
File without changes
|
{logtail_python-0.3.3 → logtail_python-0.3.4}/tests/__pycache__/test_handler.cpython-311.pyc
RENAMED
|
File without changes
|
{logtail_python-0.3.3 → logtail_python-0.3.4}/tests/__pycache__/test_helpers.cpython-311.pyc
RENAMED
|
File without changes
|
{logtail_python-0.3.3 → logtail_python-0.3.4}/tests/__pycache__/test_uploader.cpython-311.pyc
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|