devlogs 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.
Files changed (47) hide show
  1. devlogs-1.0.0/LICENSE +21 -0
  2. devlogs-1.0.0/MANIFEST.in +1 -0
  3. devlogs-1.0.0/PKG-INFO +145 -0
  4. devlogs-1.0.0/README.md +102 -0
  5. devlogs-1.0.0/pyproject.toml +46 -0
  6. devlogs-1.0.0/setup.cfg +4 -0
  7. devlogs-1.0.0/src/devlogs/__init__.py +1 -0
  8. devlogs-1.0.0/src/devlogs/cli.py +477 -0
  9. devlogs-1.0.0/src/devlogs/config.py +108 -0
  10. devlogs-1.0.0/src/devlogs/context.py +41 -0
  11. devlogs-1.0.0/src/devlogs/demo.py +228 -0
  12. devlogs-1.0.0/src/devlogs/formatting.py +34 -0
  13. devlogs-1.0.0/src/devlogs/handler.py +167 -0
  14. devlogs-1.0.0/src/devlogs/levels.py +12 -0
  15. devlogs-1.0.0/src/devlogs/mcp/__init__.py +1 -0
  16. devlogs-1.0.0/src/devlogs/mcp/server.py +726 -0
  17. devlogs-1.0.0/src/devlogs/opensearch/__init__.py +1 -0
  18. devlogs-1.0.0/src/devlogs/opensearch/client.py +202 -0
  19. devlogs-1.0.0/src/devlogs/opensearch/indexing.py +5 -0
  20. devlogs-1.0.0/src/devlogs/opensearch/mappings.py +28 -0
  21. devlogs-1.0.0/src/devlogs/opensearch/queries.py +661 -0
  22. devlogs-1.0.0/src/devlogs/retention.py +186 -0
  23. devlogs-1.0.0/src/devlogs/scrub.py +64 -0
  24. devlogs-1.0.0/src/devlogs/web/__init__.py +1 -0
  25. devlogs-1.0.0/src/devlogs/web/server.py +79 -0
  26. devlogs-1.0.0/src/devlogs/web/static/devlogs.css +342 -0
  27. devlogs-1.0.0/src/devlogs/web/static/devlogs.js +333 -0
  28. devlogs-1.0.0/src/devlogs/web/static/index.html +68 -0
  29. devlogs-1.0.0/src/devlogs.egg-info/PKG-INFO +145 -0
  30. devlogs-1.0.0/src/devlogs.egg-info/SOURCES.txt +45 -0
  31. devlogs-1.0.0/src/devlogs.egg-info/dependency_links.txt +1 -0
  32. devlogs-1.0.0/src/devlogs.egg-info/entry_points.txt +2 -0
  33. devlogs-1.0.0/src/devlogs.egg-info/requires.txt +12 -0
  34. devlogs-1.0.0/src/devlogs.egg-info/top_level.txt +1 -0
  35. devlogs-1.0.0/tests/test_cli.py +438 -0
  36. devlogs-1.0.0/tests/test_config.py +146 -0
  37. devlogs-1.0.0/tests/test_context.py +81 -0
  38. devlogs-1.0.0/tests/test_formatting.py +55 -0
  39. devlogs-1.0.0/tests/test_handler.py +389 -0
  40. devlogs-1.0.0/tests/test_indexing.py +188 -0
  41. devlogs-1.0.0/tests/test_levels.py +89 -0
  42. devlogs-1.0.0/tests/test_mcp_server.py +371 -0
  43. devlogs-1.0.0/tests/test_opensearch_client.py +398 -0
  44. devlogs-1.0.0/tests/test_opensearch_queries.py +196 -0
  45. devlogs-1.0.0/tests/test_retention.py +293 -0
  46. devlogs-1.0.0/tests/test_scrub.py +62 -0
  47. devlogs-1.0.0/tests/test_web.py +82 -0
devlogs-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 dandriscoll
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ recursive-include src/devlogs/web/static *.html *.css *.js
devlogs-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,145 @@
1
+ Metadata-Version: 2.4
2
+ Name: devlogs
3
+ Version: 1.0.0
4
+ Summary: Developer-focused logging library for Python with OpenSearch integration.
5
+ Author-email: Dan Driscoll <dan@thedandriscoll.org>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2025 dandriscoll
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Requires-Python: >=3.11
29
+ Description-Content-Type: text/markdown
30
+ License-File: LICENSE
31
+ Requires-Dist: opensearch-py>=2.4.0
32
+ Requires-Dist: click>=8.1.0
33
+ Requires-Dist: typer>=0.9.0
34
+ Requires-Dist: fastapi>=0.110.0
35
+ Requires-Dist: uvicorn>=0.24.0
36
+ Requires-Dist: python-dotenv>=1.0.0
37
+ Requires-Dist: mcp>=1.0.0
38
+ Provides-Extra: dev
39
+ Requires-Dist: httpx>=0.26.0; extra == "dev"
40
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
41
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
42
+ Dynamic: license-file
43
+
44
+ # devlogs
45
+
46
+ A developer-focused logging library for Python with OpenSearch integration.
47
+
48
+ ## Quickstart
49
+
50
+ 1. **Install devlogs:**
51
+ ```sh
52
+ pip install devlogs
53
+ ```
54
+
55
+ 2. **Start OpenSearch:**
56
+ ```sh
57
+ docker-compose up -d opensearch
58
+ ```
59
+ Or point `DEVLOGS_OPENSEARCH_*` at an existing cluster.
60
+
61
+ 3. **Initialize indices/templates:**
62
+ ```sh
63
+ devlogs init
64
+ ```
65
+
66
+ 4. **Use in Python code:**
67
+ ```python
68
+ import logging
69
+ from devlogs.handler import OpenSearchHandler
70
+ from devlogs.context import operation
71
+
72
+ handler = OpenSearchHandler(level=logging.DEBUG)
73
+ logging.getLogger().addHandler(handler)
74
+ logging.getLogger().setLevel(logging.DEBUG)
75
+
76
+ with operation(area="web"):
77
+ logging.info("Hello from devlogs!", extra={"features": {"user": "alice", "plan": "pro"}})
78
+ ```
79
+
80
+ 5. **Tail logs from CLI:**
81
+ ```sh
82
+ devlogs tail --area web --follow
83
+ ```
84
+
85
+ 6. **Search logs from CLI:**
86
+ ```sh
87
+ devlogs search --q "error" --area web
88
+ ```
89
+
90
+ 7. **Run the web UI:**
91
+ ```sh
92
+ uvicorn devlogs.web.server:app --port 8088
93
+ # Then open http://localhost:8088/ui/
94
+ ```
95
+
96
+ ## Using devlogs in another project
97
+
98
+ 1. **Install devlogs:**
99
+ ```sh
100
+ pip install devlogs
101
+ ```
102
+
103
+ 2. **Add the diagnostics handler:**
104
+ ```python
105
+ import logging
106
+ from devlogs.handler import DiagnosticsHandler
107
+ from devlogs.opensearch.client import get_opensearch_client
108
+ from devlogs.context import operation
109
+
110
+ client = get_opensearch_client()
111
+ handler = DiagnosticsHandler(opensearch_client=client, index_name="devlogs-0001")
112
+ logging.getLogger().addHandler(handler)
113
+ logging.getLogger().setLevel(logging.DEBUG)
114
+
115
+ with operation(area="web"):
116
+ logging.info("request started")
117
+ ```
118
+
119
+ ## Features
120
+
121
+ - Standard `logging.Handler` for OpenSearch
122
+ - Context manager for operation_id/area
123
+ - Structured feature pairs on log entries (`extra={"features": {...}}`)
124
+ - CLI and Linux shell wrapper
125
+ - Minimal embeddable web UI
126
+ - Robust tests (pytest)
127
+
128
+ ## Configuration
129
+
130
+ Environment variables:
131
+ - OpenSearch connection: `DEVLOGS_OPENSEARCH_HOST`, `DEVLOGS_OPENSEARCH_PORT`, `DEVLOGS_OPENSEARCH_USER`, `DEVLOGS_OPENSEARCH_PASS`
132
+ - Index: `DEVLOGS_INDEX`
133
+ - Retention (supports duration strings like `24h`, `7d`): `DEVLOGS_RETENTION_DEBUG`, `DEVLOGS_RETENTION_INFO`, `DEVLOGS_RETENTION_WARNING`
134
+
135
+ See [.env.example](.env.example) for a complete configuration template.
136
+
137
+ ## Project Structure
138
+
139
+ - `src/devlogs/` - Python library, CLI, MCP server, and web UI
140
+ - `devlogs` - Shell wrapper for local development
141
+ - `tests/` - Pytest-based tests
142
+
143
+ ## See Also
144
+
145
+ - `PROMPT.md` for full requirements
@@ -0,0 +1,102 @@
1
+ # devlogs
2
+
3
+ A developer-focused logging library for Python with OpenSearch integration.
4
+
5
+ ## Quickstart
6
+
7
+ 1. **Install devlogs:**
8
+ ```sh
9
+ pip install devlogs
10
+ ```
11
+
12
+ 2. **Start OpenSearch:**
13
+ ```sh
14
+ docker-compose up -d opensearch
15
+ ```
16
+ Or point `DEVLOGS_OPENSEARCH_*` at an existing cluster.
17
+
18
+ 3. **Initialize indices/templates:**
19
+ ```sh
20
+ devlogs init
21
+ ```
22
+
23
+ 4. **Use in Python code:**
24
+ ```python
25
+ import logging
26
+ from devlogs.handler import OpenSearchHandler
27
+ from devlogs.context import operation
28
+
29
+ handler = OpenSearchHandler(level=logging.DEBUG)
30
+ logging.getLogger().addHandler(handler)
31
+ logging.getLogger().setLevel(logging.DEBUG)
32
+
33
+ with operation(area="web"):
34
+ logging.info("Hello from devlogs!", extra={"features": {"user": "alice", "plan": "pro"}})
35
+ ```
36
+
37
+ 5. **Tail logs from CLI:**
38
+ ```sh
39
+ devlogs tail --area web --follow
40
+ ```
41
+
42
+ 6. **Search logs from CLI:**
43
+ ```sh
44
+ devlogs search --q "error" --area web
45
+ ```
46
+
47
+ 7. **Run the web UI:**
48
+ ```sh
49
+ uvicorn devlogs.web.server:app --port 8088
50
+ # Then open http://localhost:8088/ui/
51
+ ```
52
+
53
+ ## Using devlogs in another project
54
+
55
+ 1. **Install devlogs:**
56
+ ```sh
57
+ pip install devlogs
58
+ ```
59
+
60
+ 2. **Add the diagnostics handler:**
61
+ ```python
62
+ import logging
63
+ from devlogs.handler import DiagnosticsHandler
64
+ from devlogs.opensearch.client import get_opensearch_client
65
+ from devlogs.context import operation
66
+
67
+ client = get_opensearch_client()
68
+ handler = DiagnosticsHandler(opensearch_client=client, index_name="devlogs-0001")
69
+ logging.getLogger().addHandler(handler)
70
+ logging.getLogger().setLevel(logging.DEBUG)
71
+
72
+ with operation(area="web"):
73
+ logging.info("request started")
74
+ ```
75
+
76
+ ## Features
77
+
78
+ - Standard `logging.Handler` for OpenSearch
79
+ - Context manager for operation_id/area
80
+ - Structured feature pairs on log entries (`extra={"features": {...}}`)
81
+ - CLI and Linux shell wrapper
82
+ - Minimal embeddable web UI
83
+ - Robust tests (pytest)
84
+
85
+ ## Configuration
86
+
87
+ Environment variables:
88
+ - OpenSearch connection: `DEVLOGS_OPENSEARCH_HOST`, `DEVLOGS_OPENSEARCH_PORT`, `DEVLOGS_OPENSEARCH_USER`, `DEVLOGS_OPENSEARCH_PASS`
89
+ - Index: `DEVLOGS_INDEX`
90
+ - Retention (supports duration strings like `24h`, `7d`): `DEVLOGS_RETENTION_DEBUG`, `DEVLOGS_RETENTION_INFO`, `DEVLOGS_RETENTION_WARNING`
91
+
92
+ See [.env.example](.env.example) for a complete configuration template.
93
+
94
+ ## Project Structure
95
+
96
+ - `src/devlogs/` - Python library, CLI, MCP server, and web UI
97
+ - `devlogs` - Shell wrapper for local development
98
+ - `tests/` - Pytest-based tests
99
+
100
+ ## See Also
101
+
102
+ - `PROMPT.md` for full requirements
@@ -0,0 +1,46 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "devlogs"
7
+ version = "1.0.0"
8
+ description = "Developer-focused logging library for Python with OpenSearch integration."
9
+ requires-python = ">=3.11"
10
+ readme = "README.md"
11
+ license = {file = "LICENSE"}
12
+ authors = [{name = "Dan Driscoll", email = "dan@thedandriscoll.org"}]
13
+ dependencies = [
14
+ "opensearch-py>=2.4.0",
15
+ "click>=8.1.0",
16
+ "typer>=0.9.0",
17
+ "fastapi>=0.110.0",
18
+ "uvicorn>=0.24.0",
19
+ "python-dotenv>=1.0.0",
20
+ "mcp>=1.0.0",
21
+ ]
22
+
23
+ [project.optional-dependencies]
24
+ dev = [
25
+ "httpx>=0.26.0",
26
+ "pytest>=8.0.0",
27
+ "pytest-asyncio>=0.23.0",
28
+ ]
29
+
30
+ [project.scripts]
31
+ devlogs = "devlogs.cli:main"
32
+
33
+ [tool.setuptools]
34
+ package-dir = {"" = "src"}
35
+ include-package-data = true
36
+
37
+ [tool.setuptools.packages.find]
38
+ where = ["src"]
39
+
40
+ [tool.setuptools.package-data]
41
+ "devlogs.web" = ["static/*.html", "static/*.css", "static/*.js"]
42
+
43
+ [tool.pytest.ini_options]
44
+ markers = [
45
+ "integration: marks tests as integration (deselect with '-m \"not integration\"')",
46
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1 @@
1
+ # devlogs package