logtail-python 0.3.2__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.
Files changed (35) hide show
  1. {logtail_python-0.3.2/logtail_python.egg-info → logtail_python-0.3.4}/PKG-INFO +15 -3
  2. {logtail_python-0.3.2 → logtail_python-0.3.4}/logtail/__init__.py +1 -1
  3. {logtail_python-0.3.2 → logtail_python-0.3.4}/logtail/handler.py +8 -3
  4. {logtail_python-0.3.2 → logtail_python-0.3.4}/logtail/uploader.py +4 -3
  5. {logtail_python-0.3.2 → logtail_python-0.3.4/logtail_python.egg-info}/PKG-INFO +15 -3
  6. {logtail_python-0.3.2 → logtail_python-0.3.4}/setup.py +1 -1
  7. {logtail_python-0.3.2 → logtail_python-0.3.4}/tests/__pycache__/test_handler.cpython-311.pyc +0 -0
  8. {logtail_python-0.3.2 → logtail_python-0.3.4}/tests/test_flusher.py +2 -1
  9. {logtail_python-0.3.2 → logtail_python-0.3.4}/tests/test_handler.py +11 -1
  10. {logtail_python-0.3.2 → logtail_python-0.3.4}/tests/test_uploader.py +5 -2
  11. {logtail_python-0.3.2 → logtail_python-0.3.4}/LICENSE.md +0 -0
  12. {logtail_python-0.3.2 → logtail_python-0.3.4}/MANIFEST.in +0 -0
  13. {logtail_python-0.3.2 → logtail_python-0.3.4}/README.md +0 -0
  14. {logtail_python-0.3.2 → logtail_python-0.3.4}/logtail/compat.py +0 -0
  15. {logtail_python-0.3.2 → logtail_python-0.3.4}/logtail/flusher.py +0 -0
  16. {logtail_python-0.3.2 → logtail_python-0.3.4}/logtail/formatter.py +0 -0
  17. {logtail_python-0.3.2 → logtail_python-0.3.4}/logtail/frame.py +0 -0
  18. {logtail_python-0.3.2 → logtail_python-0.3.4}/logtail/helpers.py +0 -0
  19. {logtail_python-0.3.2 → logtail_python-0.3.4}/logtail_python.egg-info/SOURCES.txt +0 -0
  20. {logtail_python-0.3.2 → logtail_python-0.3.4}/logtail_python.egg-info/dependency_links.txt +0 -0
  21. {logtail_python-0.3.2 → logtail_python-0.3.4}/logtail_python.egg-info/requires.txt +0 -0
  22. {logtail_python-0.3.2 → logtail_python-0.3.4}/logtail_python.egg-info/top_level.txt +0 -0
  23. {logtail_python-0.3.2 → logtail_python-0.3.4}/requirements.txt +0 -0
  24. {logtail_python-0.3.2 → logtail_python-0.3.4}/setup.cfg +0 -0
  25. {logtail_python-0.3.2 → logtail_python-0.3.4}/test-requirements.txt +0 -0
  26. {logtail_python-0.3.2 → logtail_python-0.3.4}/tests/__init__.py +0 -0
  27. {logtail_python-0.3.2 → logtail_python-0.3.4}/tests/__pycache__/__init__.cpython-311.pyc +0 -0
  28. {logtail_python-0.3.2 → logtail_python-0.3.4}/tests/__pycache__/test_flusher.cpython-311.pyc +0 -0
  29. {logtail_python-0.3.2 → logtail_python-0.3.4}/tests/__pycache__/test_formatter.cpython-311.pyc +0 -0
  30. {logtail_python-0.3.2 → logtail_python-0.3.4}/tests/__pycache__/test_frame.cpython-311.pyc +0 -0
  31. {logtail_python-0.3.2 → logtail_python-0.3.4}/tests/__pycache__/test_helpers.cpython-311.pyc +0 -0
  32. {logtail_python-0.3.2 → logtail_python-0.3.4}/tests/__pycache__/test_uploader.cpython-311.pyc +0 -0
  33. {logtail_python-0.3.2 → logtail_python-0.3.4}/tests/test_formatter.py +0 -0
  34. {logtail_python-0.3.2 → logtail_python-0.3.4}/tests/test_frame.py +0 -0
  35. {logtail_python-0.3.2 → logtail_python-0.3.4}/tests/test_helpers.py +0 -0
@@ -1,9 +1,9 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: logtail-python
3
- Version: 0.3.2
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.2
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
 
@@ -5,6 +5,6 @@ from .handler import LogtailHandler
5
5
  from .helpers import LogtailContext, DEFAULT_CONTEXT
6
6
  from .formatter import LogtailFormatter
7
7
 
8
- __version__ = '0.3.2'
8
+ __version__ = '0.3.4'
9
9
 
10
10
  context = DEFAULT_CONTEXT
@@ -9,13 +9,14 @@ from .flusher import FlushWorker
9
9
  from .uploader import Uploader
10
10
  from .frame import create_frame
11
11
 
12
- DEFAULT_HOST = 'https://in.logs.betterstack.com'
12
+ DEFAULT_HOST = 'in.logs.betterstack.com'
13
13
  DEFAULT_BUFFER_CAPACITY = 1000
14
14
  DEFAULT_FLUSH_INTERVAL = 1
15
15
  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,13 +30,17 @@ 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
35
- self.host = host
37
+ if host.startswith('https://') or host.startswith('http://'):
38
+ self.host = host
39
+ else:
40
+ self.host = "https://" + host
36
41
  self.context = context
37
42
  self.pipe = queue.Queue(maxsize=buffer_capacity)
38
- self.uploader = Uploader(self.source_token, self.host)
43
+ self.uploader = Uploader(self.source_token, self.host, timeout)
39
44
  self.drop_extra_events = drop_extra_events
40
45
  self.include_extra_attributes = include_extra_attributes
41
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
1
+ Metadata-Version: 2.4
2
2
  Name: logtail-python
3
- Version: 0.3.2
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.2
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
 
@@ -3,7 +3,7 @@ import os
3
3
  from setuptools import setup
4
4
 
5
5
 
6
- VERSION = '0.3.2'
6
+ VERSION = '0.3.4'
7
7
  ROOT_DIR = os.path.dirname(__file__)
8
8
 
9
9
  REQUIREMENTS = [
@@ -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
 
@@ -19,7 +19,17 @@ class TestLogtailHandler(unittest.TestCase):
19
19
  def test_handler_creates_uploader_from_args(self, MockWorker):
20
20
  handler = LogtailHandler(source_token=self.source_token, host=self.host)
21
21
  self.assertEqual(handler.uploader.source_token, self.source_token)
22
- self.assertEqual(handler.uploader.host, self.host)
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