logtrace-py 1.0.0__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.
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2026 Logtrace Ltd (https://logtracehq.com)
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,10 @@
1
+ Metadata-Version: 2.4
2
+ Name: logtrace-py
3
+ Version: 1.0.0
4
+ Summary: Python client for the Logtrace API
5
+ Requires-Python: >=3.11
6
+ License-File: LICENSE
7
+ Provides-Extra: dev
8
+ Requires-Dist: pytest>=8.0; extra == "dev"
9
+ Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
10
+ Dynamic: license-file
@@ -0,0 +1,100 @@
1
+ # logtrace-py
2
+
3
+ Python client for the Logtrace API. Requires Python ≥ 3.11, no dependencies.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pip install logtrace-py
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```python
14
+ from logtrace_py import Client, CreateEventRequest
15
+
16
+ client = Client(api_key=os.environ["LOGTRACE_API_KEY"])
17
+
18
+ client.create_event(CreateEventRequest(
19
+ action_name="user.signup",
20
+ http_method="POST",
21
+ http_status=201,
22
+ client_ip="203.0.113.42",
23
+ client_user_agent=request.headers.get("User-Agent", ""),
24
+ ))
25
+
26
+ client.create_session(CreateSessionRequest(...))
27
+ client.create_audit_log(CreateAuditLogRequest(...))
28
+ ```
29
+
30
+ ### Async
31
+
32
+ ```python
33
+ from logtrace_py import AsyncClient
34
+
35
+ async with AsyncClient(api_key=os.environ["LOGTRACE_API_KEY"]) as client:
36
+ await client.create_event(CreateEventRequest(...))
37
+ ```
38
+
39
+ ## Middleware
40
+
41
+ Automatically attaches request context (IP, method, endpoint, headers, status code) to every call made inside a handler.
42
+
43
+ **WSGI (Flask)**
44
+
45
+ ```python
46
+ from logtrace_py import WsgiMiddleware
47
+
48
+ app.wsgi_app = WsgiMiddleware(app.wsgi_app, client)
49
+ ```
50
+
51
+ **ASGI (FastAPI / Starlette)**
52
+
53
+ ```python
54
+ from logtrace_py import AsgiMiddleware
55
+
56
+ app.add_middleware(AsgiMiddleware, client=client)
57
+ ```
58
+
59
+ **Django** — add to `settings.py`:
60
+
61
+ ```python
62
+ import logtrace_py
63
+ LOGTRACE_CLIENT = logtrace_py.Client(api_key=os.environ["LOGTRACE_API_KEY"])
64
+
65
+ MIDDLEWARE = [
66
+ "logtrace_py.middleware.DjangoMiddleware",
67
+ ...
68
+ ]
69
+ ```
70
+
71
+ Inside any handler:
72
+
73
+ ```python
74
+ from logtrace_py import from_context
75
+
76
+ rc = from_context(client)
77
+ rc.create_event(CreateEventRequest(...)) # sync
78
+ await rc.async_create_event(CreateEventRequest(...)) # async
79
+ ```
80
+
81
+ ## Error handling
82
+
83
+ ```python
84
+ from logtrace_py import LogtraceError
85
+
86
+ try:
87
+ client.create_event(req)
88
+ except LogtraceError as e:
89
+ print(e.status_code, e)
90
+ ```
91
+
92
+ ## Options
93
+
94
+ ```python
95
+ Client(
96
+ api_key="...",
97
+ base_url="https://api.logtrace.dev/v1/developers", # default: http://localhost:8080/v1/developers
98
+ timeout=5.0, # default: 10.0
99
+ )
100
+ ```
@@ -0,0 +1,10 @@
1
+ Metadata-Version: 2.4
2
+ Name: logtrace-py
3
+ Version: 1.0.0
4
+ Summary: Python client for the Logtrace API
5
+ Requires-Python: >=3.11
6
+ License-File: LICENSE
7
+ Provides-Extra: dev
8
+ Requires-Dist: pytest>=8.0; extra == "dev"
9
+ Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
10
+ Dynamic: license-file
@@ -0,0 +1,8 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ logtrace_py.egg-info/PKG-INFO
5
+ logtrace_py.egg-info/SOURCES.txt
6
+ logtrace_py.egg-info/dependency_links.txt
7
+ logtrace_py.egg-info/requires.txt
8
+ logtrace_py.egg-info/top_level.txt
@@ -0,0 +1,4 @@
1
+
2
+ [dev]
3
+ pytest>=8.0
4
+ pytest-asyncio>=0.23
@@ -0,0 +1,20 @@
1
+ [build-system]
2
+ requires = ["setuptools>=42", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "logtrace-py"
7
+ version = "1.0.0"
8
+ description = "Python client for the Logtrace API"
9
+ requires-python = ">=3.11"
10
+ dependencies = []
11
+
12
+ [project.optional-dependencies]
13
+ dev = ["pytest>=8.0", "pytest-asyncio>=0.23"]
14
+
15
+ [tool.setuptools.packages.find]
16
+ where = ["."]
17
+ include = ["logtrace_py*"]
18
+
19
+ [tool.pytest.ini_options]
20
+ asyncio_mode = "auto"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+