logxpy 0.1.0__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.
- logxpy/__init__.py +126 -0
- logxpy/_action.py +958 -0
- logxpy/_async.py +186 -0
- logxpy/_base.py +80 -0
- logxpy/_compat.py +71 -0
- logxpy/_config.py +45 -0
- logxpy/_dest.py +88 -0
- logxpy/_errors.py +58 -0
- logxpy/_fmt.py +68 -0
- logxpy/_generators.py +136 -0
- logxpy/_mask.py +23 -0
- logxpy/_message.py +195 -0
- logxpy/_output.py +517 -0
- logxpy/_pool.py +93 -0
- logxpy/_traceback.py +126 -0
- logxpy/_types.py +71 -0
- logxpy/_util.py +56 -0
- logxpy/_validation.py +486 -0
- logxpy/_version.py +21 -0
- logxpy/cli.py +61 -0
- logxpy/dask.py +172 -0
- logxpy/decorators.py +268 -0
- logxpy/filter.py +124 -0
- logxpy/journald.py +88 -0
- logxpy/json.py +149 -0
- logxpy/loggerx.py +253 -0
- logxpy/logwriter.py +84 -0
- logxpy/parse.py +191 -0
- logxpy/prettyprint.py +173 -0
- logxpy/serializers.py +36 -0
- logxpy/stdlib.py +23 -0
- logxpy/tai64n.py +45 -0
- logxpy/testing.py +472 -0
- logxpy/tests/__init__.py +9 -0
- logxpy/tests/common.py +36 -0
- logxpy/tests/strategies.py +231 -0
- logxpy/tests/test_action.py +1751 -0
- logxpy/tests/test_api.py +86 -0
- logxpy/tests/test_async.py +67 -0
- logxpy/tests/test_compat.py +13 -0
- logxpy/tests/test_config.py +21 -0
- logxpy/tests/test_coroutines.py +105 -0
- logxpy/tests/test_dask.py +211 -0
- logxpy/tests/test_decorators.py +54 -0
- logxpy/tests/test_filter.py +122 -0
- logxpy/tests/test_fmt.py +42 -0
- logxpy/tests/test_generators.py +292 -0
- logxpy/tests/test_journald.py +246 -0
- logxpy/tests/test_json.py +208 -0
- logxpy/tests/test_loggerx.py +44 -0
- logxpy/tests/test_logwriter.py +262 -0
- logxpy/tests/test_message.py +334 -0
- logxpy/tests/test_output.py +921 -0
- logxpy/tests/test_parse.py +309 -0
- logxpy/tests/test_pool.py +55 -0
- logxpy/tests/test_prettyprint.py +303 -0
- logxpy/tests/test_pyinstaller.py +35 -0
- logxpy/tests/test_serializers.py +36 -0
- logxpy/tests/test_stdlib.py +73 -0
- logxpy/tests/test_tai64n.py +66 -0
- logxpy/tests/test_testing.py +1051 -0
- logxpy/tests/test_traceback.py +251 -0
- logxpy/tests/test_twisted.py +814 -0
- logxpy/tests/test_util.py +45 -0
- logxpy/tests/test_validation.py +989 -0
- logxpy/twisted.py +265 -0
- logxpy-0.1.0.dist-info/METADATA +100 -0
- logxpy-0.1.0.dist-info/RECORD +72 -0
- logxpy-0.1.0.dist-info/WHEEL +5 -0
- logxpy-0.1.0.dist-info/entry_points.txt +2 -0
- logxpy-0.1.0.dist-info/licenses/LICENSE +201 -0
- logxpy-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Tests for L{eliot.serializers}.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from unittest import TestCase
|
|
6
|
+
from datetime import datetime
|
|
7
|
+
from hashlib import md5
|
|
8
|
+
|
|
9
|
+
from ..serializers import timestamp, identity, md5hex
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class SerializerTests(TestCase):
|
|
13
|
+
"""
|
|
14
|
+
Tests for standard serializers.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def test_timestamp(self):
|
|
18
|
+
"""
|
|
19
|
+
L{timestamp} converts a UTC L{datetime} to a Unicode strings.
|
|
20
|
+
"""
|
|
21
|
+
dt = datetime(2012, 9, 28, 14, 53, 6, 123456)
|
|
22
|
+
self.assertEqual(timestamp(dt), "2012-09-28T14:53:06.123456Z")
|
|
23
|
+
|
|
24
|
+
def test_identity(self):
|
|
25
|
+
"""
|
|
26
|
+
L{identity} returns the input object.
|
|
27
|
+
"""
|
|
28
|
+
obj = object()
|
|
29
|
+
self.assertIs(identity(obj), obj)
|
|
30
|
+
|
|
31
|
+
def test_md5hex(self):
|
|
32
|
+
"""
|
|
33
|
+
L{md5hex} returns the hex value of a MD5 checksum.
|
|
34
|
+
"""
|
|
35
|
+
data = b"01234456789"
|
|
36
|
+
self.assertEqual(md5hex(data), md5(data).hexdigest())
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"""Tests for standard library logging integration."""
|
|
2
|
+
|
|
3
|
+
from unittest import TestCase
|
|
4
|
+
import logging
|
|
5
|
+
import traceback
|
|
6
|
+
|
|
7
|
+
from ..testing import assertContainsFields, capture_logging
|
|
8
|
+
from ..stdlib import EliotHandler
|
|
9
|
+
from .test_traceback import assert_expected_traceback
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class StdlibTests(TestCase):
|
|
13
|
+
"""Tests for stdlib integration."""
|
|
14
|
+
|
|
15
|
+
@capture_logging(None)
|
|
16
|
+
def test_handler(self, logger):
|
|
17
|
+
"""The EliotHandler routes messages to Eliot."""
|
|
18
|
+
stdlib_logger = logging.getLogger("eliot-test")
|
|
19
|
+
stdlib_logger.setLevel(logging.DEBUG)
|
|
20
|
+
handler = EliotHandler()
|
|
21
|
+
stdlib_logger.addHandler(handler)
|
|
22
|
+
stdlib_logger.info("hello")
|
|
23
|
+
stdlib_logger.warning("ono")
|
|
24
|
+
message = logger.messages[0]
|
|
25
|
+
assertContainsFields(
|
|
26
|
+
self,
|
|
27
|
+
message,
|
|
28
|
+
{
|
|
29
|
+
"message_type": "eliot:stdlib",
|
|
30
|
+
"log_level": "INFO",
|
|
31
|
+
"message": "hello",
|
|
32
|
+
"logger": "eliot-test",
|
|
33
|
+
},
|
|
34
|
+
)
|
|
35
|
+
message = logger.messages[1]
|
|
36
|
+
assertContainsFields(
|
|
37
|
+
self,
|
|
38
|
+
message,
|
|
39
|
+
{
|
|
40
|
+
"message_type": "eliot:stdlib",
|
|
41
|
+
"log_level": "WARNING",
|
|
42
|
+
"message": "ono",
|
|
43
|
+
"logger": "eliot-test",
|
|
44
|
+
},
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
@capture_logging(None)
|
|
48
|
+
def test_traceback(self, logger):
|
|
49
|
+
"""The EliotHandler routes tracebacks to Eliot."""
|
|
50
|
+
stdlib_logger = logging.getLogger("eliot-test2")
|
|
51
|
+
stdlib_logger.setLevel(logging.DEBUG)
|
|
52
|
+
handler = EliotHandler()
|
|
53
|
+
stdlib_logger.addHandler(handler)
|
|
54
|
+
try:
|
|
55
|
+
raise RuntimeError()
|
|
56
|
+
except Exception as e:
|
|
57
|
+
exception = e
|
|
58
|
+
expected_traceback = traceback.format_exc()
|
|
59
|
+
stdlib_logger.exception("ono")
|
|
60
|
+
message = logger.messages[0]
|
|
61
|
+
assertContainsFields(
|
|
62
|
+
self,
|
|
63
|
+
message,
|
|
64
|
+
{
|
|
65
|
+
"message_type": "eliot:stdlib",
|
|
66
|
+
"log_level": "ERROR",
|
|
67
|
+
"message": "ono",
|
|
68
|
+
"logger": "eliot-test2",
|
|
69
|
+
},
|
|
70
|
+
)
|
|
71
|
+
assert_expected_traceback(
|
|
72
|
+
self, logger, logger.messages[1], exception, expected_traceback
|
|
73
|
+
)
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Tests for L{eliot.tai64n}.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import errno
|
|
6
|
+
import time
|
|
7
|
+
import subprocess
|
|
8
|
+
from unittest import TestCase, SkipTest
|
|
9
|
+
|
|
10
|
+
from ..tai64n import encode, decode
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class CodecTests(TestCase):
|
|
14
|
+
"""
|
|
15
|
+
Tests for L{encode} and L{decode}.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
def test_encode(self):
|
|
19
|
+
"""
|
|
20
|
+
L{encode} encodes timestamps in TAI64N format.
|
|
21
|
+
"""
|
|
22
|
+
t = 1387299889.153187625
|
|
23
|
+
self.assertEqual(encode(t), "@4000000052b0843b092174b9")
|
|
24
|
+
|
|
25
|
+
def test_decode(self):
|
|
26
|
+
"""
|
|
27
|
+
L{decode} decodes timestamps from TAI64N format.
|
|
28
|
+
"""
|
|
29
|
+
t = time.time()
|
|
30
|
+
self.assertAlmostEqual(t, decode(encode(t)), 9)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class FunctionalTests(TestCase):
|
|
34
|
+
"""
|
|
35
|
+
Functional tests for L{encode}.
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
def test_encode(self):
|
|
39
|
+
"""
|
|
40
|
+
The daemontools tai64nlocal tool can correctly decode timestamps output
|
|
41
|
+
by L{encode}.
|
|
42
|
+
"""
|
|
43
|
+
try:
|
|
44
|
+
process = subprocess.Popen(
|
|
45
|
+
["tai64nlocal"],
|
|
46
|
+
bufsize=4096,
|
|
47
|
+
stdin=subprocess.PIPE,
|
|
48
|
+
stdout=subprocess.PIPE,
|
|
49
|
+
)
|
|
50
|
+
except OSError as e:
|
|
51
|
+
if e.errno == errno.ENOENT:
|
|
52
|
+
raise SkipTest("This test requires the daemontools package")
|
|
53
|
+
else:
|
|
54
|
+
raise
|
|
55
|
+
# Because of limitations of the time libraries tai64nlocal uses we
|
|
56
|
+
# apparently can't verify beyond this level of accuracy.
|
|
57
|
+
timestamp = int(time.time()) + 0.12345
|
|
58
|
+
process.stdin.write((encode(timestamp) + "\n").encode("ascii"))
|
|
59
|
+
process.stdin.close()
|
|
60
|
+
decodedToLocalTime = process.stdout.read().strip()
|
|
61
|
+
self.assertEqual(
|
|
62
|
+
time.strftime("%Y-%m-%d %H:%M:%S.12345", time.localtime(timestamp)).encode(
|
|
63
|
+
"ascii"
|
|
64
|
+
),
|
|
65
|
+
decodedToLocalTime[:25],
|
|
66
|
+
)
|