logtail-python 0.3.3__py2.py3-none-any.whl → 0.4.0__py2.py3-none-any.whl

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/__init__.py CHANGED
@@ -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.3'
8
+ __version__ = '0.4.0'
9
9
 
10
10
  context = DEFAULT_CONTEXT
logtail/flusher.py CHANGED
@@ -26,6 +26,16 @@ class FlushWorker(threading.Thread):
26
26
  while self.should_run:
27
27
  self.step()
28
28
 
29
+ def _is_parent_alive(self):
30
+ try:
31
+ return self.parent_thread.is_alive()
32
+ except RuntimeError:
33
+ # Starting with Python 3.14, calling is_alive() on an
34
+ # already-terminated thread raises a RuntimeError instead of
35
+ # returning False (see the parent thread being torn down during
36
+ # interpreter shutdown). Treat that as "no longer alive".
37
+ return False
38
+
29
39
  def step(self):
30
40
  last_flush = time.time()
31
41
  time_remaining = _initial_time_remaining(self.flush_interval)
@@ -34,7 +44,7 @@ class FlushWorker(threading.Thread):
34
44
 
35
45
  # If the parent thread has exited but there are still outstanding
36
46
  # events, attempt to send them before exiting.
37
- shutdown = not self.parent_thread.is_alive()
47
+ shutdown = not self._is_parent_alive()
38
48
 
39
49
  # Fill phase: take events out of the queue and group them for sending.
40
50
  # Takes up to `buffer_capacity` events out of the queue and groups them
@@ -54,11 +64,11 @@ class FlushWorker(threading.Thread):
54
64
  except queue.Empty:
55
65
  if shutdown or self._flushing:
56
66
  break
57
- shutdown = not self.parent_thread.is_alive()
67
+ shutdown = not self._is_parent_alive()
58
68
  time_remaining = _calculate_time_remaining(last_flush, self.flush_interval)
59
69
 
60
70
  # Send phase: takes the outstanding events (up to `buffer_capacity`
61
- # count) and sends them to the Logtail endpoint all at once. If the
71
+ # count) and sends them to the Better Stack endpoint all at once. If the
62
72
  # request fails in a way that can be retried, it is retried with an
63
73
  # exponential backoff in between attempts.
64
74
  if frame:
logtail/handler.py CHANGED
@@ -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
logtail/uploader.py CHANGED
@@ -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.3
4
- Summary: Logtail.com client library
3
+ Version: 0.4.0
4
+ Summary: Better Stack client library
5
5
  Home-page: https://github.com/logtail/logtail-python
6
- Download-URL: https://github.com/logtail/logtail-python/tarball/0.3.3
6
+ Download-URL: https://github.com/logtail/logtail-python/tarball/0.4.0
7
7
  Author: Logtail
8
8
  Author-email: hello@logtail.com
9
9
  License: ISC
@@ -12,17 +12,31 @@ Classifier: Intended Audience :: Developers
12
12
  Classifier: License :: OSI Approved :: ISC License (ISCL)
13
13
  Classifier: Operating System :: OS Independent
14
14
  Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3.7
16
- Classifier: Programming Language :: Python :: 3.8
17
- Classifier: Programming Language :: Python :: 3.9
18
15
  Classifier: Programming Language :: Python :: 3.10
19
16
  Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
20
  Classifier: Programming Language :: Python
21
21
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Requires-Python: >=3.10
22
23
  Description-Content-Type: text/markdown
23
24
  License-File: LICENSE.md
24
25
  Requires-Dist: requests>=2.18.4
25
26
  Requires-Dist: msgpack>=0.5.6
27
+ Dynamic: author
28
+ Dynamic: author-email
29
+ Dynamic: classifier
30
+ Dynamic: description
31
+ Dynamic: description-content-type
32
+ Dynamic: download-url
33
+ Dynamic: home-page
34
+ Dynamic: keywords
35
+ Dynamic: license
36
+ Dynamic: license-file
37
+ Dynamic: requires-dist
38
+ Dynamic: requires-python
39
+ Dynamic: summary
26
40
 
27
41
  # [Better Stack](https://betterstack.com/logs) Python client
28
42
 
@@ -0,0 +1,13 @@
1
+ logtail/__init__.py,sha256=lz_ouCpEkpsK8Lq9fCQ7Sqj8xbowot6JzNZGFeEfOrI,252
2
+ logtail/compat.py,sha256=KbZmcmDpj_vbMotp16pADPwJ1FkEHGDNjKbOfCy-c10,141
3
+ logtail/flusher.py,sha256=KKb4IEuPC_XGKaNBrbMEiwc-X4MKsYURPjY7PqR3v4k,4176
4
+ logtail/formatter.py,sha256=nk4W1G95P19ijylPBJ8D9FlO_qbh3tfbv7xzCSfpDN8,968
5
+ logtail/frame.py,sha256=p7vVYcajZvjH4FJDt4ADLfYljVbQXKTGKk3kFec5JUs,3335
6
+ logtail/handler.py,sha256=9PNJPSc2S3W5uQADKE4iDFH16A7BZW90D-m7aR66Mo4,3188
7
+ logtail/helpers.py,sha256=ezDTLsTBAtCtIh_XptSYOiBrZFa-E9wo2SWTnjKgOOU,1156
8
+ logtail/uploader.py,sha256=Ilhh8wuAGlz1YJcQpzXtFqwD-2RYmuamKv3dFNoTWUg,868
9
+ logtail_python-0.4.0.dist-info/licenses/LICENSE.md,sha256=aCBMqxfm7QNyFR9JiJ2GSMvhAURXN2E0yTcYNQloqI0,737
10
+ logtail_python-0.4.0.dist-info/METADATA,sha256=Bwsctru3-I0ZkrvKuukF6j1jDB7P1nz5OYyBmBsw79M,2429
11
+ logtail_python-0.4.0.dist-info/WHEEL,sha256=TdQ5LtNwLuxTCjgxN51AgdU5w-KkB9ttmLbzjTH02pg,109
12
+ logtail_python-0.4.0.dist-info/top_level.txt,sha256=QZIbQogN1yFBgjiJ-8NlYArVCL00gBoYbEUT_Ew8l-Q,8
13
+ logtail_python-0.4.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.44.0)
2
+ Generator: setuptools (82.0.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py2-none-any
5
5
  Tag: py3-none-any
@@ -1,13 +0,0 @@
1
- logtail/__init__.py,sha256=pN_9c2sjBTPGcCzqC_1tagX39PMCZ8Sdt4F8mFpnFOI,252
2
- logtail/compat.py,sha256=KbZmcmDpj_vbMotp16pADPwJ1FkEHGDNjKbOfCy-c10,141
3
- logtail/flusher.py,sha256=5P9MY6wn8H2rF72DEEtN6X5NTpxCZXFvmMzoUj3QcsE,3749
4
- logtail/formatter.py,sha256=nk4W1G95P19ijylPBJ8D9FlO_qbh3tfbv7xzCSfpDN8,968
5
- logtail/frame.py,sha256=p7vVYcajZvjH4FJDt4ADLfYljVbQXKTGKk3kFec5JUs,3335
6
- logtail/handler.py,sha256=JPRGBTMaHQbZW2O_0ONkogsFGdgeSLKaXSTLuxfB0UQ,3116
7
- logtail/helpers.py,sha256=ezDTLsTBAtCtIh_XptSYOiBrZFa-E9wo2SWTnjKgOOU,1156
8
- logtail/uploader.py,sha256=qBhQjXKMKId4dHC1BRSgajQ6Zh-jOygQEnc5oj2zuN0,805
9
- logtail_python-0.3.3.dist-info/LICENSE.md,sha256=aCBMqxfm7QNyFR9JiJ2GSMvhAURXN2E0yTcYNQloqI0,737
10
- logtail_python-0.3.3.dist-info/METADATA,sha256=4jjOyaSEr-aF_8B5VKgoJ-rkSO0S_gkelAdAkYSJm4c,2125
11
- logtail_python-0.3.3.dist-info/WHEEL,sha256=fS9sRbCBHs7VFcwJLnLXN1MZRR0_TVTxvXKzOnaSFs8,110
12
- logtail_python-0.3.3.dist-info/top_level.txt,sha256=QZIbQogN1yFBgjiJ-8NlYArVCL00gBoYbEUT_Ew8l-Q,8
13
- logtail_python-0.3.3.dist-info/RECORD,,