mermaid-trace 0.4.1__py3-none-any.whl → 0.6.0.post0__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.
- mermaid_trace/__init__.py +53 -21
- mermaid_trace/cli.py +168 -86
- mermaid_trace/core/config.py +55 -0
- mermaid_trace/core/decorators.py +401 -196
- mermaid_trace/core/events.py +13 -143
- mermaid_trace/core/formatter.py +176 -18
- mermaid_trace/core/utils.py +96 -0
- mermaid_trace/handlers/async_handler.py +123 -47
- mermaid_trace/handlers/mermaid_handler.py +152 -86
- mermaid_trace/integrations/__init__.py +9 -0
- mermaid_trace/integrations/fastapi.py +101 -46
- mermaid_trace/integrations/langchain.py +312 -0
- mermaid_trace/server.py +406 -0
- mermaid_trace-0.6.0.post0.dist-info/METADATA +272 -0
- mermaid_trace-0.6.0.post0.dist-info/RECORD +21 -0
- mermaid_trace-0.4.1.dist-info/METADATA +0 -180
- mermaid_trace-0.4.1.dist-info/RECORD +0 -16
- {mermaid_trace-0.4.1.dist-info → mermaid_trace-0.6.0.post0.dist-info}/WHEEL +0 -0
- {mermaid_trace-0.4.1.dist-info → mermaid_trace-0.6.0.post0.dist-info}/entry_points.txt +0 -0
- {mermaid_trace-0.4.1.dist-info → mermaid_trace-0.6.0.post0.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
mermaid_trace/__init__.py,sha256=EnAsz6R6ag4dtabdHEg1wdB2k7V1uwmwpYTTC41GQX4,6721
|
|
2
|
+
mermaid_trace/cli.py,sha256=FCbm9kHf7B74bvkRv_k7stTeG7S7GqNSITmUQW1kJEA,16173
|
|
3
|
+
mermaid_trace/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
mermaid_trace/server.py,sha256=1nNIS6pNAn3_XCwuoUkKIOsq4GJK5o33QFzv-hh-IJY,15458
|
|
5
|
+
mermaid_trace/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
mermaid_trace/core/config.py,sha256=akTOc3m_bzcZ7e1Qtf1n5Ct9Dj8XPTTcWzATG3-qJHw,1890
|
|
7
|
+
mermaid_trace/core/context.py,sha256=wr-Ys3c6PsYCtbPUsQTrnaciSkP-fofxOewo4oZ27QM,8556
|
|
8
|
+
mermaid_trace/core/decorators.py,sha256=2h7UzjQcL46jrCIdVMWSZT_4JlTsDkpY9M9Ihr0vuq4,23037
|
|
9
|
+
mermaid_trace/core/events.py,sha256=2etS45A40GaP4dF_F6Jh99rhF2YVip4AjoZlLPuP6pQ,1949
|
|
10
|
+
mermaid_trace/core/formatter.py,sha256=3KEq236E3GAj_j53MuBM2ndWm7Kx4KeywJWmoY5o568,11038
|
|
11
|
+
mermaid_trace/core/utils.py,sha256=FagsMYLZcbmOgKmRo3v9tcRNVIpuc1YEKTAjcRk7keY,3410
|
|
12
|
+
mermaid_trace/handlers/async_handler.py,sha256=WmLcULXHasapt7-W0p_Eltjmwvlq6r6BS6pViuseZ4w,8252
|
|
13
|
+
mermaid_trace/handlers/mermaid_handler.py,sha256=Czar6JYSPTu5L1fQC0I8v1UpToD6aE_r96IkPpRSByw,6142
|
|
14
|
+
mermaid_trace/integrations/__init__.py,sha256=stWAHIL1zv21foaXFXZ_3SLxJ8icN0YFGWOvvHERCDI,269
|
|
15
|
+
mermaid_trace/integrations/fastapi.py,sha256=6LRs4Z508l38ymfj5SP39vOV6OLfYLRkpxyL_SxvudM,9483
|
|
16
|
+
mermaid_trace/integrations/langchain.py,sha256=n1M2-OYNMsKiMpfGj04cs_dLyn2t5T9APmgAZsqqm5Q,10598
|
|
17
|
+
mermaid_trace-0.6.0.post0.dist-info/METADATA,sha256=kIvprKuj4jiOxpTaqumiqclh3euhw_7BkeZWg3i-YyE,10954
|
|
18
|
+
mermaid_trace-0.6.0.post0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
19
|
+
mermaid_trace-0.6.0.post0.dist-info/entry_points.txt,sha256=WS57KT_870v0A4B87QDjQUqJcddMQxbCQyYeczDAX34,57
|
|
20
|
+
mermaid_trace-0.6.0.post0.dist-info/licenses/LICENSE,sha256=BrBog1Etiq9PdWy0SVQNVByIMD9ss4Edz-R0oXt49zA,1062
|
|
21
|
+
mermaid_trace-0.6.0.post0.dist-info/RECORD,,
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: mermaid-trace
|
|
3
|
-
Version: 0.4.1
|
|
4
|
-
Summary: Visualize your Python code execution flow as Mermaid Sequence Diagrams.
|
|
5
|
-
Project-URL: Documentation, https://github.com/xt765/mermaid-trace#readme
|
|
6
|
-
Project-URL: Changelog, https://github.com/xt765/mermaid-trace/blob/main/docs/en/CHANGELOG.md
|
|
7
|
-
Project-URL: Issues, https://github.com/xt765/mermaid-trace/issues
|
|
8
|
-
Project-URL: Source, https://github.com/xt765/mermaid-trace
|
|
9
|
-
Author-email: xt765 <xt765@foxmail.com>
|
|
10
|
-
License: MIT License
|
|
11
|
-
|
|
12
|
-
Copyright (c) 2026 xt765
|
|
13
|
-
|
|
14
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
16
|
-
in the Software without restriction, including without limitation the rights
|
|
17
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
19
|
-
furnished to do so, subject to the following conditions:
|
|
20
|
-
|
|
21
|
-
The above copyright notice and this permission notice shall be included in all
|
|
22
|
-
copies or substantial portions of the Software.
|
|
23
|
-
|
|
24
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
-
SOFTWARE.
|
|
31
|
-
License-File: LICENSE
|
|
32
|
-
Keywords: asyncio,logging,mermaid,mermaid-trace,sequence-diagram,trace,visualization
|
|
33
|
-
Classifier: Development Status :: 4 - Beta
|
|
34
|
-
Classifier: Intended Audience :: Developers
|
|
35
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
36
|
-
Classifier: Operating System :: OS Independent
|
|
37
|
-
Classifier: Programming Language :: Python
|
|
38
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
39
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
40
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
41
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
42
|
-
Classifier: Programming Language :: Python :: 3.14
|
|
43
|
-
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
44
|
-
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
45
|
-
Classifier: Topic :: Software Development :: Debuggers
|
|
46
|
-
Classifier: Topic :: System :: Logging
|
|
47
|
-
Requires-Python: >=3.10
|
|
48
|
-
Requires-Dist: typing-extensions>=4.0.0
|
|
49
|
-
Requires-Dist: watchdog>=2.0.0
|
|
50
|
-
Provides-Extra: all
|
|
51
|
-
Requires-Dist: fastapi>=0.100.0; extra == 'all'
|
|
52
|
-
Provides-Extra: dev
|
|
53
|
-
Requires-Dist: fastapi>=0.100.0; extra == 'dev'
|
|
54
|
-
Requires-Dist: httpx; extra == 'dev'
|
|
55
|
-
Requires-Dist: mypy; extra == 'dev'
|
|
56
|
-
Requires-Dist: pytest; extra == 'dev'
|
|
57
|
-
Requires-Dist: pytest-asyncio; extra == 'dev'
|
|
58
|
-
Requires-Dist: pytest-cov; extra == 'dev'
|
|
59
|
-
Requires-Dist: ruff; extra == 'dev'
|
|
60
|
-
Provides-Extra: fastapi
|
|
61
|
-
Requires-Dist: fastapi>=0.100.0; extra == 'fastapi'
|
|
62
|
-
Description-Content-Type: text/markdown
|
|
63
|
-
|
|
64
|
-
# MermaidTrace: The Python Logger That Draws Diagrams
|
|
65
|
-
|
|
66
|
-
🌐 **Language**: [English](README.md) | [中文](README_CN.md)
|
|
67
|
-
|
|
68
|
-
[](https://pypi.org/project/mermaid-trace/)
|
|
69
|
-
[](https://pypi.org/project/mermaid-trace/)
|
|
70
|
-
[](LICENSE)
|
|
71
|
-
[](https://github.com/xt765/mermaid-trace/actions/workflows/ci.yml)
|
|
72
|
-
[](https://codecov.io/gh/xt765/mermaid-trace)
|
|
73
|
-
|
|
74
|
-
---
|
|
75
|
-
|
|
76
|
-
## 📋 Overview
|
|
77
|
-
|
|
78
|
-
**Stop reading logs. Start watching them.**
|
|
79
|
-
|
|
80
|
-
MermaidTrace is a specialized logging tool that automatically generates [Mermaid JS](https://mermaid.js.org/) sequence diagrams from your code execution. It's perfect for visualizing complex business logic, microservice interactions, or asynchronous flows.
|
|
81
|
-
|
|
82
|
-
---
|
|
83
|
-
|
|
84
|
-
## 📚 Documentation
|
|
85
|
-
|
|
86
|
-
[User Guide](docs/en/USER_GUIDE.md) · [API Reference](docs/en/API.md) · [Contributing Guidelines](docs/en/CONTRIBUTING.md) · [Changelog](docs/en/CHANGELOG.md) · [License](docs/en/LICENSE)
|
|
87
|
-
|
|
88
|
-
---
|
|
89
|
-
|
|
90
|
-
## ✨ Key Features
|
|
91
|
-
|
|
92
|
-
- **Decorator-Driven**: Just add `@trace` or `@trace_interaction` to your functions.
|
|
93
|
-
- **Auto-Diagramming**: Generates `.mmd` files that can be viewed in VS Code, GitHub, or Mermaid Live Editor.
|
|
94
|
-
- **Async Support**: Works seamlessly with `asyncio` coroutines.
|
|
95
|
-
- **Context Inference**: Automatically tracks nested calls and infers `source` participants using `contextvars`.
|
|
96
|
-
- **FastAPI Integration**: Includes middleware for zero-config HTTP request tracing.
|
|
97
|
-
- **CLI Tool**: Built-in viewer to preview diagrams in your browser.
|
|
98
|
-
|
|
99
|
-
---
|
|
100
|
-
|
|
101
|
-
## 🚀 Quick Start
|
|
102
|
-
|
|
103
|
-
### Installation
|
|
104
|
-
|
|
105
|
-
```bash
|
|
106
|
-
pip install mermaid-trace
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
### Basic Usage
|
|
110
|
-
|
|
111
|
-
```python
|
|
112
|
-
from mermaid_trace import trace, configure_flow
|
|
113
|
-
import time
|
|
114
|
-
|
|
115
|
-
# 1. Configure output
|
|
116
|
-
configure_flow("my_flow.mmd")
|
|
117
|
-
|
|
118
|
-
# 2. Add decorators
|
|
119
|
-
@trace(source="Client", target="PaymentService", action="Process Payment")
|
|
120
|
-
def process_payment(amount):
|
|
121
|
-
if check_balance(amount):
|
|
122
|
-
return "Success"
|
|
123
|
-
return "Failed"
|
|
124
|
-
|
|
125
|
-
@trace(source="PaymentService", target="Database", action="Check Balance")
|
|
126
|
-
def check_balance(amount):
|
|
127
|
-
return True
|
|
128
|
-
|
|
129
|
-
# 3. Run your code
|
|
130
|
-
process_payment(100)
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
### Nested Calls (Context Inference)
|
|
134
|
-
|
|
135
|
-
You don't need to specify `source` every time. MermaidTrace infers it from the current context.
|
|
136
|
-
|
|
137
|
-
```python
|
|
138
|
-
@trace(source="Client", target="API")
|
|
139
|
-
def main():
|
|
140
|
-
# Inside here, current participant is "API"
|
|
141
|
-
service_call()
|
|
142
|
-
|
|
143
|
-
@trace(target="Service") # source inferred as "API"
|
|
144
|
-
def service_call():
|
|
145
|
-
pass
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
### FastAPI Integration
|
|
149
|
-
|
|
150
|
-
```python
|
|
151
|
-
from fastapi import FastAPI
|
|
152
|
-
from mermaid_trace.integrations.fastapi import MermaidTraceMiddleware
|
|
153
|
-
|
|
154
|
-
app = FastAPI()
|
|
155
|
-
app.add_middleware(MermaidTraceMiddleware, app_name="MyAPI")
|
|
156
|
-
|
|
157
|
-
@app.get("/")
|
|
158
|
-
async def root():
|
|
159
|
-
return {"message": "Hello World"}
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
### CLI Viewer
|
|
163
|
-
|
|
164
|
-
Visualize your generated `.mmd` files instantly:
|
|
165
|
-
|
|
166
|
-
```bash
|
|
167
|
-
mermaid-trace serve my_flow.mmd
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
---
|
|
171
|
-
|
|
172
|
-
## 🤝 Contributing
|
|
173
|
-
|
|
174
|
-
We welcome contributions! Please see [CONTRIBUTING.md](docs/en/CONTRIBUTING.md) for details.
|
|
175
|
-
|
|
176
|
-
---
|
|
177
|
-
|
|
178
|
-
## 📄 License
|
|
179
|
-
|
|
180
|
-
MIT
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
mermaid_trace/__init__.py,sha256=ZXviz2KlX0eER7FPZJG2edsXfyDewt5iXpfGMifBoyE,5323
|
|
2
|
-
mermaid_trace/cli.py,sha256=w7xh9kvyaokcUcuwIsBAtgwcl9zW8mosXesp5e0CtHg,11224
|
|
3
|
-
mermaid_trace/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
mermaid_trace/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
-
mermaid_trace/core/context.py,sha256=wr-Ys3c6PsYCtbPUsQTrnaciSkP-fofxOewo4oZ27QM,8556
|
|
6
|
-
mermaid_trace/core/decorators.py,sha256=lNNx_Qj2cDJkPX67qPl3NBH946ofoJ8osqxq3oBoCgU,16164
|
|
7
|
-
mermaid_trace/core/events.py,sha256=h1g8uk1SGUj_NzefuJXYrkWO8ZuezeFjfU8IpYILnB8,5977
|
|
8
|
-
mermaid_trace/core/formatter.py,sha256=A9ULgcu3xHiG3iD6k54sQ7nm9kHceMvplVCHw_nu09I,5259
|
|
9
|
-
mermaid_trace/handlers/async_handler.py,sha256=Cbs6ZuKywf2VWwSIPNRXFOtoPArIhoYl-QHeW05hhWg,4272
|
|
10
|
-
mermaid_trace/handlers/mermaid_handler.py,sha256=rF-S3IXsMvTS-6kgGN7By-_2kqlCyMwcNgaorlci1Q8,5137
|
|
11
|
-
mermaid_trace/integrations/fastapi.py,sha256=H9Hl2pFxdbM3NwqONyJ7kAP-oGdOOnuoG3hEEbpoOjE,6487
|
|
12
|
-
mermaid_trace-0.4.1.dist-info/METADATA,sha256=JLDyn-TuDnehsO34g6GAArjIl-XN4izSVZIVulmiu6c,6539
|
|
13
|
-
mermaid_trace-0.4.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
14
|
-
mermaid_trace-0.4.1.dist-info/entry_points.txt,sha256=WS57KT_870v0A4B87QDjQUqJcddMQxbCQyYeczDAX34,57
|
|
15
|
-
mermaid_trace-0.4.1.dist-info/licenses/LICENSE,sha256=BrBog1Etiq9PdWy0SVQNVByIMD9ss4Edz-R0oXt49zA,1062
|
|
16
|
-
mermaid_trace-0.4.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|