evan-logger 0.1.1__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 @@
1
+ MIT License.
@@ -0,0 +1,311 @@
1
+ Metadata-Version: 2.4
2
+ Name: evan-logger
3
+ Version: 0.1.1
4
+ Summary: Structured colored logger with trace/span context and sampling
5
+ Author-email: Evan <e2002florespulido@gmail.com>
6
+ License: MIT License.
7
+ Project-URL: Homepage, https://github.com/EvanFloresLv/Logger.git
8
+ Project-URL: Repository, https://github.com/EvanFloresLv/Logger.git
9
+ Keywords: logging,colorlog,structured-logging,trace
10
+ Requires-Python: >=3.10
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: pydantic>=2.12.5
14
+ Requires-Dist: tomli>=2.4.0
15
+ Requires-Dist: pydantic-settings>=2.0
16
+ Requires-Dist: colorlog>=6.7.0
17
+ Requires-Dist: python-dotenv>=1.2.1
18
+ Requires-Dist: pytest>=9.0.2
19
+ Dynamic: license-file
20
+
21
+ # Project logger
22
+
23
+ A production-ready Python logging framework designed for modern backends and AI pipelines.
24
+
25
+ It supports:
26
+ - Structured JSON logs (ELK / GCP Logging / Datadog ready)
27
+ - Trace + Span IDs (contextvars, async-safe)
28
+ - Automatic context (file:line Class.method())
29
+ - Per-module log levels
30
+ - Sampling filters for hot paths (reduce noise + cost)
31
+
32
+ ---
33
+
34
+ ## Table of Contents
35
+
36
+ - [Overview](#overview)
37
+ - [Architecture](#architecture)
38
+ - [Features](#features)
39
+ - [Installation](#installation)
40
+ - [Usage](#usage)
41
+ - [Configuration](#configuration)
42
+ - [Project Structure](#project-structure)
43
+ - [Development](#development)
44
+ - [Testing](#testing)
45
+ - [Deployment](#deployment)
46
+ - [Roadmap](#roadmap)
47
+ - [Contributing](#contributing)
48
+ - [License](#license)
49
+ - [Contact](#contact)
50
+
51
+ ---
52
+
53
+ ## Overview
54
+
55
+ This project provides a clean, extensible logging layer for Python services.
56
+
57
+ It’s built to solve common production pain points:
58
+ - Logs without structure are hard to search
59
+ - Async + threads break context
60
+ - Trace correlation is missing
61
+ - Hot loops spam logs and increase cloud costs
62
+ - Large codebases need per-module control
63
+
64
+ This logger provides a single unified API for:
65
+ - console logs (pretty + colored)
66
+ - file logs (JSON structured)
67
+ - trace/span correlation
68
+ - sampling
69
+
70
+ ---
71
+
72
+ ## Architecture
73
+
74
+ ```
75
+ LoggerConfig
76
+
77
+ Logger (singleton)
78
+
79
+ logging.Logger (stdlib)
80
+
81
+ Handlers
82
+ ├── Console handler (colored)
83
+ └── File handler (.log or .json)
84
+
85
+ Filters
86
+ └── SamplingFilter
87
+ └── DeterministicFilter
88
+
89
+ ContextLogger (LoggerAdapter)
90
+ ├── context
91
+ ├── trace_id
92
+ └── span_id
93
+ ```
94
+
95
+ ### Core Components:
96
+
97
+ 1. **API Layer:** Interfaces (CLI, SDK, REST) for uploading and managing files
98
+ 2. **Service Layer:** Business logic for versioning and lifecycle rules
99
+ 3. **Repository Layer:** Abstract persistence interfaces for storage and metadata
100
+ 4. **Infrastructure Layer:** Cloud storage providers and NoSQL database adapters
101
+
102
+ ---
103
+
104
+ ## Features
105
+
106
+ 1. Structured JSON logging
107
+ - Compatible with ELK, GCP Logging, Datadog, Splunk
108
+ - Includes context, trace_id, span_id, module, function, line, exception
109
+
110
+ 2. Trace + Span IDs
111
+ - Uses contextvars (async-safe)
112
+ - Supports manual trace/span injection
113
+
114
+ 3. Automatic context resolution
115
+ - Adds file:line Class.method() automatically
116
+ - Works for functions, methods, decorators
117
+
118
+ 4. Per-module log levels
119
+ - Example: src.core=WARNING while the rest stays INFO
120
+
121
+ 5. Sampling filter
122
+ - Sample DEBUG/INFO logs for noisy paths
123
+ - Always keep WARNING/ERROR/CRITICAL
124
+
125
+ 6. Singleton logger factory
126
+ - Global configuration
127
+ - Safe Logger.configure(...) entrypoint
128
+
129
+ ---
130
+
131
+ ## Installation
132
+ ```bash
133
+ pip install <url>
134
+ ```
135
+
136
+
137
+ Or install from source:
138
+
139
+ ```bash
140
+ git clone <url>
141
+ cd project-name
142
+ pip install -e .
143
+ ```
144
+
145
+ ---
146
+
147
+ ### Usage
148
+
149
+ Basic setup
150
+ ```python
151
+ import logging
152
+ from src.logger import Logger
153
+ from src.config import LoggerConfig
154
+
155
+ Logger.configure(
156
+ LoggerConfig(
157
+ name="app",
158
+ level=logging.INFO,
159
+ directory="logs",
160
+ json_logs=True,
161
+ sample_rate=0.2,
162
+ module_levels={
163
+ "src.core": logging.WARNING,
164
+ },
165
+ )
166
+ )
167
+
168
+ logger = Logger().bind("startup")
169
+ logger.info("Service initialized")
170
+ ```
171
+
172
+ Trace + ID span
173
+
174
+ ```python
175
+ from src.logger import Logger
176
+
177
+ log = Logger()
178
+ log.set_trace()
179
+ log.set_span()
180
+
181
+ logger = log.bind("request")
182
+ logger.info("Request started")
183
+ ```
184
+
185
+ JSON logs example output
186
+ ```json
187
+ {
188
+ "timestamp": "2026-02-04T10:55:01.140Z",
189
+ "level": "INFO",
190
+ "message": "Request started",
191
+ "logger": "app",
192
+ "context": "api.py:88 EDDController.calculate()",
193
+ "trace_id": "a1f29c...",
194
+ "span_id": "91c77d...",
195
+ "module": "api",
196
+ "function": "calculate",
197
+ "line": 88
198
+ }
199
+ ```
200
+
201
+ ---
202
+
203
+ ### Configuration
204
+
205
+ Configuration is done through LoggerConfig.
206
+
207
+ Example:
208
+
209
+ ```python
210
+ from src.config import LoggerConfig
211
+
212
+ config = LoggerConfig(
213
+ name="service",
214
+ directory="logs",
215
+ json_logs=True,
216
+ sample_rate=0.1,
217
+ level=logging.INFO,
218
+ module_levels={
219
+ "src.core": logging.WARNING,
220
+ "google": logging.ERROR,
221
+ "httpx": logging.ERROR,
222
+ },
223
+ )
224
+ ```
225
+
226
+ Key settings
227
+
228
+ | Field | Meaning |
229
+ |----------------|------------------------------------------------|
230
+ | json_logs | Output JSON logs for file handler |
231
+ | directory | Where log files are stored |
232
+ | deterministic | Enable deterministic logging |
233
+ | sample_rate | Sampling probability for INFO/DEBUG |
234
+ | module_levels | Per-module log level override |
235
+ | level | Global log level |
236
+ | name | Logger name |
237
+
238
+ ---
239
+
240
+ ### Project Structure
241
+
242
+ ```
243
+ src/
244
+ ├── logger.py # Logger singleton + ContextLogger
245
+ ├── config.py # LoggerConfig + JSONFormatter + SamplingFilter
246
+ ├── core/
247
+ │ ├── filters.py # Log filtering logic
248
+ │ ├── formatters.py # Log formatting logic
249
+ │ └── tracer.py # contextvars trace_id/span_id
250
+ └── decorators/
251
+ ├── functions.py # function_log decorator
252
+ └── classes.py # class_log decorator
253
+
254
+ ```
255
+ ---
256
+
257
+ ### Development
258
+ ```bash
259
+ pip install -r requirements-dev.txt
260
+ ```
261
+
262
+ ---
263
+
264
+ ### Testing
265
+ ```
266
+ pytest tests/
267
+ ```
268
+
269
+ ---
270
+
271
+ ### Deployment
272
+
273
+ The service can be deployed as:
274
+
275
+ ```
276
+ Python SDK library
277
+ FastAPI microservice
278
+ Serverless function (Cloud Run / Lambda / Azure Functions)
279
+ Internal data platform component
280
+ ```
281
+
282
+ ---
283
+
284
+ ### Roadmap
285
+
286
+ 1. Request middleware integration for Flask/FastAPI
287
+ 2. Deterministic sampling by trace_id (avoid partial traces)
288
+ 3. Rotating file handler support
289
+ 4. OpenTelemetry bridge
290
+ 5. Log batching / async writer for high throughput
291
+
292
+ ---
293
+
294
+ ### Contributing
295
+
296
+ Contributions are welcome.
297
+ Please follow the coding standards and submit PRs with tests and documentation updates.
298
+
299
+ ---
300
+
301
+ ### License
302
+
303
+ MIT License.
304
+
305
+ ---
306
+
307
+ ### Contact
308
+
309
+ Maintainer: Evan Flores
310
+ Email: *efloresp06@liverpool.com.mx*
311
+ Organization: **Liverpool**
@@ -0,0 +1,291 @@
1
+ # Project logger
2
+
3
+ A production-ready Python logging framework designed for modern backends and AI pipelines.
4
+
5
+ It supports:
6
+ - Structured JSON logs (ELK / GCP Logging / Datadog ready)
7
+ - Trace + Span IDs (contextvars, async-safe)
8
+ - Automatic context (file:line Class.method())
9
+ - Per-module log levels
10
+ - Sampling filters for hot paths (reduce noise + cost)
11
+
12
+ ---
13
+
14
+ ## Table of Contents
15
+
16
+ - [Overview](#overview)
17
+ - [Architecture](#architecture)
18
+ - [Features](#features)
19
+ - [Installation](#installation)
20
+ - [Usage](#usage)
21
+ - [Configuration](#configuration)
22
+ - [Project Structure](#project-structure)
23
+ - [Development](#development)
24
+ - [Testing](#testing)
25
+ - [Deployment](#deployment)
26
+ - [Roadmap](#roadmap)
27
+ - [Contributing](#contributing)
28
+ - [License](#license)
29
+ - [Contact](#contact)
30
+
31
+ ---
32
+
33
+ ## Overview
34
+
35
+ This project provides a clean, extensible logging layer for Python services.
36
+
37
+ It’s built to solve common production pain points:
38
+ - Logs without structure are hard to search
39
+ - Async + threads break context
40
+ - Trace correlation is missing
41
+ - Hot loops spam logs and increase cloud costs
42
+ - Large codebases need per-module control
43
+
44
+ This logger provides a single unified API for:
45
+ - console logs (pretty + colored)
46
+ - file logs (JSON structured)
47
+ - trace/span correlation
48
+ - sampling
49
+
50
+ ---
51
+
52
+ ## Architecture
53
+
54
+ ```
55
+ LoggerConfig
56
+
57
+ Logger (singleton)
58
+
59
+ logging.Logger (stdlib)
60
+
61
+ Handlers
62
+ ├── Console handler (colored)
63
+ └── File handler (.log or .json)
64
+
65
+ Filters
66
+ └── SamplingFilter
67
+ └── DeterministicFilter
68
+
69
+ ContextLogger (LoggerAdapter)
70
+ ├── context
71
+ ├── trace_id
72
+ └── span_id
73
+ ```
74
+
75
+ ### Core Components:
76
+
77
+ 1. **API Layer:** Interfaces (CLI, SDK, REST) for uploading and managing files
78
+ 2. **Service Layer:** Business logic for versioning and lifecycle rules
79
+ 3. **Repository Layer:** Abstract persistence interfaces for storage and metadata
80
+ 4. **Infrastructure Layer:** Cloud storage providers and NoSQL database adapters
81
+
82
+ ---
83
+
84
+ ## Features
85
+
86
+ 1. Structured JSON logging
87
+ - Compatible with ELK, GCP Logging, Datadog, Splunk
88
+ - Includes context, trace_id, span_id, module, function, line, exception
89
+
90
+ 2. Trace + Span IDs
91
+ - Uses contextvars (async-safe)
92
+ - Supports manual trace/span injection
93
+
94
+ 3. Automatic context resolution
95
+ - Adds file:line Class.method() automatically
96
+ - Works for functions, methods, decorators
97
+
98
+ 4. Per-module log levels
99
+ - Example: src.core=WARNING while the rest stays INFO
100
+
101
+ 5. Sampling filter
102
+ - Sample DEBUG/INFO logs for noisy paths
103
+ - Always keep WARNING/ERROR/CRITICAL
104
+
105
+ 6. Singleton logger factory
106
+ - Global configuration
107
+ - Safe Logger.configure(...) entrypoint
108
+
109
+ ---
110
+
111
+ ## Installation
112
+ ```bash
113
+ pip install <url>
114
+ ```
115
+
116
+
117
+ Or install from source:
118
+
119
+ ```bash
120
+ git clone <url>
121
+ cd project-name
122
+ pip install -e .
123
+ ```
124
+
125
+ ---
126
+
127
+ ### Usage
128
+
129
+ Basic setup
130
+ ```python
131
+ import logging
132
+ from src.logger import Logger
133
+ from src.config import LoggerConfig
134
+
135
+ Logger.configure(
136
+ LoggerConfig(
137
+ name="app",
138
+ level=logging.INFO,
139
+ directory="logs",
140
+ json_logs=True,
141
+ sample_rate=0.2,
142
+ module_levels={
143
+ "src.core": logging.WARNING,
144
+ },
145
+ )
146
+ )
147
+
148
+ logger = Logger().bind("startup")
149
+ logger.info("Service initialized")
150
+ ```
151
+
152
+ Trace + ID span
153
+
154
+ ```python
155
+ from src.logger import Logger
156
+
157
+ log = Logger()
158
+ log.set_trace()
159
+ log.set_span()
160
+
161
+ logger = log.bind("request")
162
+ logger.info("Request started")
163
+ ```
164
+
165
+ JSON logs example output
166
+ ```json
167
+ {
168
+ "timestamp": "2026-02-04T10:55:01.140Z",
169
+ "level": "INFO",
170
+ "message": "Request started",
171
+ "logger": "app",
172
+ "context": "api.py:88 EDDController.calculate()",
173
+ "trace_id": "a1f29c...",
174
+ "span_id": "91c77d...",
175
+ "module": "api",
176
+ "function": "calculate",
177
+ "line": 88
178
+ }
179
+ ```
180
+
181
+ ---
182
+
183
+ ### Configuration
184
+
185
+ Configuration is done through LoggerConfig.
186
+
187
+ Example:
188
+
189
+ ```python
190
+ from src.config import LoggerConfig
191
+
192
+ config = LoggerConfig(
193
+ name="service",
194
+ directory="logs",
195
+ json_logs=True,
196
+ sample_rate=0.1,
197
+ level=logging.INFO,
198
+ module_levels={
199
+ "src.core": logging.WARNING,
200
+ "google": logging.ERROR,
201
+ "httpx": logging.ERROR,
202
+ },
203
+ )
204
+ ```
205
+
206
+ Key settings
207
+
208
+ | Field | Meaning |
209
+ |----------------|------------------------------------------------|
210
+ | json_logs | Output JSON logs for file handler |
211
+ | directory | Where log files are stored |
212
+ | deterministic | Enable deterministic logging |
213
+ | sample_rate | Sampling probability for INFO/DEBUG |
214
+ | module_levels | Per-module log level override |
215
+ | level | Global log level |
216
+ | name | Logger name |
217
+
218
+ ---
219
+
220
+ ### Project Structure
221
+
222
+ ```
223
+ src/
224
+ ├── logger.py # Logger singleton + ContextLogger
225
+ ├── config.py # LoggerConfig + JSONFormatter + SamplingFilter
226
+ ├── core/
227
+ │ ├── filters.py # Log filtering logic
228
+ │ ├── formatters.py # Log formatting logic
229
+ │ └── tracer.py # contextvars trace_id/span_id
230
+ └── decorators/
231
+ ├── functions.py # function_log decorator
232
+ └── classes.py # class_log decorator
233
+
234
+ ```
235
+ ---
236
+
237
+ ### Development
238
+ ```bash
239
+ pip install -r requirements-dev.txt
240
+ ```
241
+
242
+ ---
243
+
244
+ ### Testing
245
+ ```
246
+ pytest tests/
247
+ ```
248
+
249
+ ---
250
+
251
+ ### Deployment
252
+
253
+ The service can be deployed as:
254
+
255
+ ```
256
+ Python SDK library
257
+ FastAPI microservice
258
+ Serverless function (Cloud Run / Lambda / Azure Functions)
259
+ Internal data platform component
260
+ ```
261
+
262
+ ---
263
+
264
+ ### Roadmap
265
+
266
+ 1. Request middleware integration for Flask/FastAPI
267
+ 2. Deterministic sampling by trace_id (avoid partial traces)
268
+ 3. Rotating file handler support
269
+ 4. OpenTelemetry bridge
270
+ 5. Log batching / async writer for high throughput
271
+
272
+ ---
273
+
274
+ ### Contributing
275
+
276
+ Contributions are welcome.
277
+ Please follow the coding standards and submit PRs with tests and documentation updates.
278
+
279
+ ---
280
+
281
+ ### License
282
+
283
+ MIT License.
284
+
285
+ ---
286
+
287
+ ### Contact
288
+
289
+ Maintainer: Evan Flores
290
+ Email: *efloresp06@liverpool.com.mx*
291
+ Organization: **Liverpool**
@@ -0,0 +1,31 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "evan-logger"
7
+ version = "0.1.1"
8
+ description = "Structured colored logger with trace/span context and sampling"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = { file = "LICENSE" }
12
+ authors = [{ name="Evan", email="e2002florespulido@gmail.com" }]
13
+ keywords = ["logging", "colorlog", "structured-logging", "trace"]
14
+ dependencies = [
15
+ "pydantic>=2.12.5",
16
+ "tomli>=2.4.0",
17
+ "pydantic-settings>=2.0",
18
+ "colorlog>=6.7.0",
19
+ "python-dotenv>=1.2.1",
20
+ "pytest>=9.0.2"
21
+ ]
22
+
23
+ [project.urls]
24
+ Homepage = "https://github.com/EvanFloresLv/Logger.git"
25
+ Repository = "https://github.com/EvanFloresLv/Logger.git"
26
+
27
+ [tool.setuptools]
28
+ package-dir = {"" = "src"}
29
+
30
+ [tool.setuptools.packages.find]
31
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+