unitlog 0.0.1__tar.gz → 0.0.2__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.
unitlog-0.0.2/PKG-INFO ADDED
@@ -0,0 +1,33 @@
1
+ Metadata-Version: 2.1
2
+ Name: unitlog
3
+ Version: 0.0.2
4
+ Home-page: https://github.com/yujun2647/unitlog
5
+ Download-URL:
6
+ Author: walkerjun
7
+ Author-email: yujun2647@163.com
8
+ License: Apache-2.0
9
+ Requires-Python: >=3.6
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+
13
+ # unitlog
14
+
15
+ ## About
16
+
17
+ manage log sending through one process
18
+
19
+ ## Usage
20
+
21
+ ```python
22
+ import logging
23
+
24
+ from unitlog.unit import register_logger
25
+
26
+ logger1 = logging.getLogger("test1")
27
+
28
+ register_logger(name=logger1.name, file_log=True,
29
+ log_filepath="./temp/test1.log")
30
+
31
+ logger1.info("hello")
32
+
33
+ ```
@@ -0,0 +1,21 @@
1
+ # unitlog
2
+
3
+ ## About
4
+
5
+ manage log sending through one process
6
+
7
+ ## Usage
8
+
9
+ ```python
10
+ import logging
11
+
12
+ from unitlog.unit import register_logger
13
+
14
+ logger1 = logging.getLogger("test1")
15
+
16
+ register_logger(name=logger1.name, file_log=True,
17
+ log_filepath="./temp/test1.log")
18
+
19
+ logger1.info("hello")
20
+
21
+ ```
@@ -0,0 +1,105 @@
1
+ import os
2
+ import logging
3
+
4
+ import multiprocessing as mp
5
+ import time
6
+
7
+ from threading import Thread
8
+ from unitlog.unit import register_logger, DEFAULT_LOG
9
+ from unittest import TestCase
10
+
11
+ os.environ["ENV-TEST"] = "test"
12
+
13
+ logger1 = logging.getLogger("test1")
14
+ logger2 = logging.getLogger("test2")
15
+ logger3 = logging.getLogger("test3")
16
+
17
+
18
+ def test_thread(start=0, end=100):
19
+ for i in range(start, end):
20
+ logger1.info(i)
21
+
22
+
23
+ def test_thread2(start=0, end=100):
24
+ for i in range(start, end):
25
+ logger2.info(i)
26
+
27
+
28
+ def test_thread3(start=0, end=100):
29
+ for i in range(start, end):
30
+ logger3.info(i)
31
+
32
+
33
+ class TestMultiLogger(TestCase):
34
+
35
+ def setUp(self):
36
+ DEFAULT_LOG.log_num.value = 0
37
+ logger1.parent = None
38
+ logger1.propagate = False
39
+ logger2.parent = None
40
+ logger2.propagate = False
41
+ logger3.parent = None
42
+ logger3.propagate = False
43
+ logger1.handlers.clear()
44
+ logger2.handlers.clear()
45
+ logger3.handlers.clear()
46
+
47
+ def test_multi_logger(self):
48
+ register_logger(name=logger1.name, file_log=True,
49
+ log_filepath="./temp/test_logger1.log")
50
+ register_logger(name=logger2.name, file_log=True,
51
+ log_filepath="./temp/test_logger2.log",
52
+ parent_logger_name=logger1.name)
53
+ register_logger(name=logger3.name, file_log=True,
54
+ log_filepath="./temp/test_logger3.log",
55
+ parent_logger_name=logger2.name)
56
+
57
+ Thread(target=test_thread, args=(1, 101)).start()
58
+ Thread(target=test_thread, args=(101, 201)).start()
59
+ Thread(target=test_thread2, args=(201, 301)).start()
60
+ Thread(target=test_thread2, args=(301, 401)).start()
61
+ mp.Process(target=test_thread3, args=(401, 501)).start()
62
+ mp.Process(target=test_thread3, args=(501, 601)).start()
63
+ time.sleep(1)
64
+
65
+ expect_log_num = 201 * 2 + 201 * 2 * 2 + 201 * 2 * 3
66
+ assert DEFAULT_LOG.log_num.value == expect_log_num, \
67
+ f"log num is {DEFAULT_LOG.log_num.value}"
68
+
69
+ def test_multi_worker(self):
70
+ logger = register_logger(name=logger1.name)
71
+
72
+ Thread(target=test_thread, args=(1, 101)).start()
73
+ Thread(target=test_thread, args=(101, 201)).start()
74
+ Thread(target=test_thread, args=(201, 301)).start()
75
+ Thread(target=test_thread, args=(301, 401)).start()
76
+ mp.Process(target=test_thread, args=(401, 501)).start()
77
+ mp.Process(target=test_thread, args=(501, 601)).start()
78
+ mp.Process(target=test_thread, args=(601, 701)).start()
79
+ mp.Process(target=test_thread, args=(701, 801)).start()
80
+ mp.Process(target=test_thread, args=(801, 901)).start()
81
+ mp.Process(target=test_thread, args=(901, 1001)).start()
82
+
83
+ time.sleep(1)
84
+ assert DEFAULT_LOG.log_num.value == 1000, \
85
+ f"log num is {DEFAULT_LOG.log_num.value}"
86
+
87
+ def test_multi_worker_with_file_log(self):
88
+ register_logger(
89
+ name=logger1.name, file_log=True,
90
+ log_filepath="./temp/multi_worker_with_file_log.log")
91
+
92
+ Thread(target=test_thread, args=(1, 101)).start()
93
+ Thread(target=test_thread, args=(101, 201)).start()
94
+ Thread(target=test_thread, args=(201, 301)).start()
95
+ Thread(target=test_thread, args=(301, 401)).start()
96
+ mp.Process(target=test_thread, args=(401, 501)).start()
97
+ mp.Process(target=test_thread, args=(501, 601)).start()
98
+ mp.Process(target=test_thread, args=(601, 701)).start()
99
+ mp.Process(target=test_thread, args=(701, 801)).start()
100
+ mp.Process(target=test_thread, args=(801, 901)).start()
101
+ mp.Process(target=test_thread, args=(901, 1001)).start()
102
+
103
+ time.sleep(1)
104
+ assert DEFAULT_LOG.log_num.value == 2002, \
105
+ f"log num is {DEFAULT_LOG.log_num.value}"
@@ -0,0 +1 @@
1
+ __version__ = "0.0.2"
@@ -0,0 +1,33 @@
1
+ Metadata-Version: 2.1
2
+ Name: unitlog
3
+ Version: 0.0.2
4
+ Home-page: https://github.com/yujun2647/unitlog
5
+ Download-URL:
6
+ Author: walkerjun
7
+ Author-email: yujun2647@163.com
8
+ License: Apache-2.0
9
+ Requires-Python: >=3.6
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+
13
+ # unitlog
14
+
15
+ ## About
16
+
17
+ manage log sending through one process
18
+
19
+ ## Usage
20
+
21
+ ```python
22
+ import logging
23
+
24
+ from unitlog.unit import register_logger
25
+
26
+ logger1 = logging.getLogger("test1")
27
+
28
+ register_logger(name=logger1.name, file_log=True,
29
+ log_filepath="./temp/test1.log")
30
+
31
+ logger1.info("hello")
32
+
33
+ ```
@@ -1,6 +1,7 @@
1
1
  LICENSE
2
2
  README.md
3
3
  setup.py
4
+ test/test_multi_logger.py
4
5
  unitlog/__init__.py
5
6
  unitlog/handlers.py
6
7
  unitlog/unit.py
unitlog-0.0.1/PKG-INFO DELETED
@@ -1,11 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: unitlog
3
- Version: 0.0.1
4
- Home-page: https://github.com/yujun2647/unitlog
5
- Download-URL:
6
- Author: walkerjun
7
- Author-email: yujun2647@163.com
8
- License: Apache-2.0
9
- Requires-Python: >=3.6
10
- Description-Content-Type: text/markdown
11
- License-File: LICENSE
unitlog-0.0.1/README.md DELETED
File without changes
@@ -1 +0,0 @@
1
- __version__ = "0.0.1"
@@ -1,11 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: unitlog
3
- Version: 0.0.1
4
- Home-page: https://github.com/yujun2647/unitlog
5
- Download-URL:
6
- Author: walkerjun
7
- Author-email: yujun2647@163.com
8
- License: Apache-2.0
9
- Requires-Python: >=3.6
10
- Description-Content-Type: text/markdown
11
- License-File: LICENSE
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes