liblogging 0.1.5__tar.gz → 0.1.7__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.
- {liblogging-0.1.5 → liblogging-0.1.7}/PKG-INFO +25 -1
- liblogging-0.1.7/README.md +27 -0
- {liblogging-0.1.5 → liblogging-0.1.7}/liblogging/util.py +20 -0
- {liblogging-0.1.5 → liblogging-0.1.7}/liblogging.egg-info/PKG-INFO +25 -1
- {liblogging-0.1.5 → liblogging-0.1.7}/setup.py +1 -1
- liblogging-0.1.5/README.md +0 -3
- {liblogging-0.1.5 → liblogging-0.1.7}/LICENSE +0 -0
- {liblogging-0.1.5 → liblogging-0.1.7}/liblogging/__init__.py +0 -0
- {liblogging-0.1.5 → liblogging-0.1.7}/liblogging/logger.py +0 -0
- {liblogging-0.1.5 → liblogging-0.1.7}/liblogging.egg-info/SOURCES.txt +0 -0
- {liblogging-0.1.5 → liblogging-0.1.7}/liblogging.egg-info/dependency_links.txt +0 -0
- {liblogging-0.1.5 → liblogging-0.1.7}/liblogging.egg-info/top_level.txt +0 -0
- {liblogging-0.1.5 → liblogging-0.1.7}/liblogging.egg-info/zip-safe +0 -0
- {liblogging-0.1.5 → liblogging-0.1.7}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: liblogging
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.7
|
|
4
4
|
Summary: Utilities for logging and sending logs.
|
|
5
5
|
Home-page: https://github.com/XoriieInpottn/liblogging
|
|
6
6
|
Author: xi
|
|
@@ -23,3 +23,27 @@ Dynamic: summary
|
|
|
23
23
|
# liblogging
|
|
24
24
|
|
|
25
25
|
Utilities for logging and sending logs.
|
|
26
|
+
|
|
27
|
+
# Usage
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
from liblogging.logger import logger
|
|
31
|
+
|
|
32
|
+
# Log a simple message
|
|
33
|
+
logger.info("This is an info message")
|
|
34
|
+
|
|
35
|
+
# Log a message with context
|
|
36
|
+
logger.track_start("Starting process", message_type="process_start")
|
|
37
|
+
logger.track_end("Ending process", message_type="process_end")
|
|
38
|
+
|
|
39
|
+
# Log a request
|
|
40
|
+
@log_request("user_id", "session_id")
|
|
41
|
+
def process_request(user_id, session_id):
|
|
42
|
+
logger.info("Processing request")
|
|
43
|
+
|
|
44
|
+
process_request(user_id=123, session_id="abc")
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
# Tips
|
|
48
|
+
|
|
49
|
+
1. If using Kafka to send messages, please use `kafka-python==2.0.2`.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# liblogging
|
|
2
|
+
|
|
3
|
+
Utilities for logging and sending logs.
|
|
4
|
+
|
|
5
|
+
# Usage
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
from liblogging.logger import logger
|
|
9
|
+
|
|
10
|
+
# Log a simple message
|
|
11
|
+
logger.info("This is an info message")
|
|
12
|
+
|
|
13
|
+
# Log a message with context
|
|
14
|
+
logger.track_start("Starting process", message_type="process_start")
|
|
15
|
+
logger.track_end("Ending process", message_type="process_end")
|
|
16
|
+
|
|
17
|
+
# Log a request
|
|
18
|
+
@log_request("user_id", "session_id")
|
|
19
|
+
def process_request(user_id, session_id):
|
|
20
|
+
logger.info("Processing request")
|
|
21
|
+
|
|
22
|
+
process_request(user_id=123, session_id="abc")
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
# Tips
|
|
26
|
+
|
|
27
|
+
1. If using Kafka to send messages, please use `kafka-python==2.0.2`.
|
|
@@ -9,6 +9,7 @@ __all__ = [
|
|
|
9
9
|
import uuid
|
|
10
10
|
from typing import Dict, Union, Tuple
|
|
11
11
|
from datetime import datetime
|
|
12
|
+
from concurrent.futures import Future, ThreadPoolExecutor
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
def get_trace_id(
|
|
@@ -61,3 +62,22 @@ def split_trace_id(trace_id: str, combine_symbol: str = "+") -> Tuple:
|
|
|
61
62
|
except ValueError:
|
|
62
63
|
pass
|
|
63
64
|
return trace_id, {}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class ThreadPoolManager:
|
|
68
|
+
"""Thread pool manager
|
|
69
|
+
usage:
|
|
70
|
+
import thread_pool_manager
|
|
71
|
+
futures = [thread_pool_manager.submit(your function, args), thread_pool_manager.submit(your function, args), ...]
|
|
72
|
+
for future in futures:
|
|
73
|
+
print(future.result())
|
|
74
|
+
"""
|
|
75
|
+
|
|
76
|
+
def __init__(self, max_workers: int = None):
|
|
77
|
+
self.executor = ThreadPoolExecutor(max_workers=max_workers)
|
|
78
|
+
|
|
79
|
+
def submit(self, func, *args, **kwargs) -> Future:
|
|
80
|
+
return self.executor.submit(func, *args, **kwargs)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
thread_pool_manager = ThreadPoolManager()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: liblogging
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.7
|
|
4
4
|
Summary: Utilities for logging and sending logs.
|
|
5
5
|
Home-page: https://github.com/XoriieInpottn/liblogging
|
|
6
6
|
Author: xi
|
|
@@ -23,3 +23,27 @@ Dynamic: summary
|
|
|
23
23
|
# liblogging
|
|
24
24
|
|
|
25
25
|
Utilities for logging and sending logs.
|
|
26
|
+
|
|
27
|
+
# Usage
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
from liblogging.logger import logger
|
|
31
|
+
|
|
32
|
+
# Log a simple message
|
|
33
|
+
logger.info("This is an info message")
|
|
34
|
+
|
|
35
|
+
# Log a message with context
|
|
36
|
+
logger.track_start("Starting process", message_type="process_start")
|
|
37
|
+
logger.track_end("Ending process", message_type="process_end")
|
|
38
|
+
|
|
39
|
+
# Log a request
|
|
40
|
+
@log_request("user_id", "session_id")
|
|
41
|
+
def process_request(user_id, session_id):
|
|
42
|
+
logger.info("Processing request")
|
|
43
|
+
|
|
44
|
+
process_request(user_id=123, session_id="abc")
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
# Tips
|
|
48
|
+
|
|
49
|
+
1. If using Kafka to send messages, please use `kafka-python==2.0.2`.
|
liblogging-0.1.5/README.md
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|