log2fast-fastapi 0.1.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 (27) hide show
  1. log2fast_fastapi-0.1.0/LICENSE +21 -0
  2. log2fast_fastapi-0.1.0/MANIFEST.in +8 -0
  3. log2fast_fastapi-0.1.0/PKG-INFO +287 -0
  4. log2fast_fastapi-0.1.0/README.md +232 -0
  5. log2fast_fastapi-0.1.0/docs/env.example +149 -0
  6. log2fast_fastapi-0.1.0/docs/file_management.md +492 -0
  7. log2fast_fastapi-0.1.0/docs/file_management_es.md +492 -0
  8. log2fast_fastapi-0.1.0/docs/logger_best_practices.md +383 -0
  9. log2fast_fastapi-0.1.0/docs/usage.md +518 -0
  10. log2fast_fastapi-0.1.0/examples/demo_features.py +225 -0
  11. log2fast_fastapi-0.1.0/examples/demo_rotation.py +228 -0
  12. log2fast_fastapi-0.1.0/examples/example.py +124 -0
  13. log2fast_fastapi-0.1.0/pyproject.toml +67 -0
  14. log2fast_fastapi-0.1.0/setup.cfg +4 -0
  15. log2fast_fastapi-0.1.0/src/log2fast_fastapi/__init__.py +27 -0
  16. log2fast_fastapi-0.1.0/src/log2fast_fastapi/__version__.py +5 -0
  17. log2fast_fastapi-0.1.0/src/log2fast_fastapi/base.py +342 -0
  18. log2fast_fastapi-0.1.0/src/log2fast_fastapi/formatters.py +148 -0
  19. log2fast_fastapi-0.1.0/src/log2fast_fastapi/middleware.py +106 -0
  20. log2fast_fastapi-0.1.0/src/log2fast_fastapi/settings.py +187 -0
  21. log2fast_fastapi-0.1.0/src/log2fast_fastapi.egg-info/PKG-INFO +287 -0
  22. log2fast_fastapi-0.1.0/src/log2fast_fastapi.egg-info/SOURCES.txt +25 -0
  23. log2fast_fastapi-0.1.0/src/log2fast_fastapi.egg-info/dependency_links.txt +1 -0
  24. log2fast_fastapi-0.1.0/src/log2fast_fastapi.egg-info/requires.txt +9 -0
  25. log2fast_fastapi-0.1.0/src/log2fast_fastapi.egg-info/top_level.txt +1 -0
  26. log2fast_fastapi-0.1.0/tests/test_enviroment_feature.py +120 -0
  27. log2fast_fastapi-0.1.0/tests/test_logging.py +327 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Angel Daniel Sanchez Castillo
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,8 @@
1
+ include README.md
2
+ include LICENSE
3
+ recursive-include docs *.md *.example
4
+ recursive-include examples *.py
5
+ recursive-include src/log2fast_fastapi *.py
6
+ global-exclude __pycache__
7
+ global-exclude *.py[co]
8
+ global-exclude .DS_Store
@@ -0,0 +1,287 @@
1
+ Metadata-Version: 2.4
2
+ Name: log2fast-fastapi
3
+ Version: 0.1.0
4
+ Summary: Advanced logging module for FastAPI - Designed for Solautyc Team internal use
5
+ Author-email: Angel Daniel Sanchez Castillo <angeldaniel.sanchezcastillo@gmail.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 Angel Daniel Sanchez Castillo
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
+ Project-URL: Homepage, https://github.com/AngelDanielSanchezCastillo/log2fast-fastapi
29
+ Project-URL: Documentation, https://github.com/AngelDanielSanchezCastillo/log2fast-fastapi/tree/main/docs
30
+ Project-URL: Repository, https://github.com/AngelDanielSanchezCastillo/log2fast-fastapi
31
+ Project-URL: Issues, https://github.com/AngelDanielSanchezCastillo/log2fast-fastapi/issues
32
+ Keywords: fastapi,logging,rotation,colored-logs,structured-logging,middleware
33
+ Classifier: Development Status :: 3 - Alpha
34
+ Classifier: Intended Audience :: Developers
35
+ Classifier: License :: OSI Approved :: MIT License
36
+ Classifier: Programming Language :: Python :: 3
37
+ Classifier: Programming Language :: Python :: 3.10
38
+ Classifier: Programming Language :: Python :: 3.11
39
+ Classifier: Programming Language :: Python :: 3.12
40
+ Classifier: Framework :: FastAPI
41
+ Classifier: Topic :: System :: Logging
42
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
43
+ Requires-Python: >=3.10
44
+ Description-Content-Type: text/markdown
45
+ License-File: LICENSE
46
+ Requires-Dist: fastapi>=0.100.0
47
+ Requires-Dist: pydantic>=2.0.0
48
+ Requires-Dist: pydantic-settings>=2.0.0
49
+ Provides-Extra: dev
50
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
51
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
52
+ Requires-Dist: httpx>=0.24.0; extra == "dev"
53
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
54
+ Dynamic: license-file
55
+
56
+ # log2fast-fastapi
57
+
58
+ 🚀 Advanced logging module for FastAPI with file rotation, colored output, and environment-based auto-configuration
59
+
60
+ > [!WARNING]
61
+ > **Internal Use Notice**
62
+ >
63
+ > This package is designed and maintained by the **Solautyc Team** for internal use. While it is publicly available, it may not work as expected in all environments or use cases outside of our specific infrastructure. We do not provide support or guarantees for external usage, and we are not responsible for any issues that may arise from using this package in other contexts.
64
+ >
65
+ > Use at your own risk. Contributions and feedback are welcome, but compatibility with external environments is not guaranteed.
66
+
67
+ ## Features
68
+
69
+ - 🎨 **Multiple Output Formats**: JSON (production), Colored (development), Structured (debugging), Simple (testing)
70
+ - 🌍 **Environment-Based Configuration**: Automatic setup for dev, test, prod, and debug
71
+ - 📦 **Module-Based Loggers**: Each module gets its own logger instance
72
+ - 🔄 **File Rotation**: Automatic log file rotation with configurable size
73
+ - 🔄 **Environment-Specific Logging**: Control which logs appear in which environments (prevent sensitive data leaks)
74
+ - 🚀 **FastAPI Integration**: Middleware for automatic request/response logging with unique request IDs
75
+ - 📊 **Structured Logging**: Add context data to any log message
76
+ - 📊 **Context Injection**: Support for request_id, user_id, and custom context data
77
+ - 🎯 **Zero Configuration**: Works out of the box with sensible defaults
78
+
79
+ ## 📚 Documentation
80
+
81
+ - **[Usage Guide](docs/usage.md)** - Comprehensive usage guide with examples
82
+ - **[File Management](docs/file_management.md)** - Complete guide on log rotation and storage (English)
83
+ - **[Gestión de Archivos](docs/file_management_es.md)** - Guía completa de rotación y almacenamiento (Español)
84
+ - **[Logger Best Practices](docs/logger_best_practices.md)** - Best practices for creating and naming loggers
85
+
86
+
87
+ ## Installation
88
+
89
+ ### From PyPI (Recommended)
90
+
91
+ ```bash
92
+ pip install log2fast-fastapi
93
+ ```
94
+
95
+ ### From Source
96
+
97
+ ```bash
98
+ # Clone the repository
99
+ git clone https://github.com/AngelDanielSanchezCastillo/log2fast-fastapi.git
100
+ cd log2fast-fastapi
101
+
102
+ # Install in development mode
103
+ pip install -e .
104
+
105
+ # Or install with dev dependencies
106
+ pip install -e ".[dev]"
107
+ ```
108
+
109
+
110
+ ## Quick Start
111
+
112
+ ### Basic Usage
113
+
114
+ ```python
115
+ from log2fast_fastapi import get_logger
116
+
117
+ logger = get_logger(__name__)
118
+
119
+ logger.info("Application started")
120
+ logger.warning("This is a warning")
121
+ logger.error("An error occurred")
122
+ ```
123
+
124
+ ### FastAPI Integration
125
+
126
+ ```python
127
+ from fastapi import FastAPI
128
+ from log2fast_fastapi import RequestLoggingMiddleware, get_logger
129
+
130
+ app = FastAPI()
131
+ app.add_middleware(RequestLoggingMiddleware)
132
+
133
+ logger = get_logger(__name__)
134
+
135
+ @app.get("/")
136
+ async def root():
137
+ logger.info("Root endpoint accessed")
138
+ return {"message": "Hello World"}
139
+ ```
140
+
141
+ ### Logging with Context
142
+
143
+ ```python
144
+ from log2fast_fastapi import get_logger
145
+
146
+ logger = get_logger(__name__)
147
+
148
+ logger.info(
149
+ "User logged in",
150
+ extra_data={
151
+ "user_id": "12345",
152
+ "ip_address": "192.168.1.1"
153
+ }
154
+ )
155
+ ```
156
+
157
+ ### Environment-Specific Logging (Prevent Sensitive Data Leaks!)
158
+
159
+ ```python
160
+ # Logs ONLY in development/debug (NOT in production)
161
+ logger.debug(
162
+ "Sensitive debug info",
163
+ extra_data={"password_hash": "...", "token": "..."},
164
+ only_in=["development", "debug"]
165
+ )
166
+
167
+ # Logs ONLY in production
168
+ logger.info(
169
+ "Performance metrics",
170
+ extra_data={"response_time": 120},
171
+ only_in=["production"]
172
+ )
173
+ ```
174
+
175
+ ## Configuration
176
+
177
+ **Simple: Just set the environment in `.env`**
178
+
179
+ ```bash
180
+ # That's it! Format and level auto-configure
181
+ LOG_ENVIRONMENT=production
182
+ ```
183
+
184
+ Auto-configuration by environment:
185
+
186
+ | Environment | Auto Level | Auto Format |
187
+ |------------|-----------|-------------|
188
+ | `development` | INFO | colored |
189
+ | `production` | WARNING | json |
190
+ | `testing` | INFO | simple |
191
+ | `debug` | DEBUG | colored |
192
+
193
+ **Optional: Override defaults**
194
+
195
+
196
+ ```bash
197
+ # Optional: Override auto-configuration
198
+ LOG_LEVEL=DEBUG
199
+ LOG_FORMAT=json
200
+ LOG_FILE_SETTINGS__ENABLED=true
201
+ ```
202
+
203
+ ## Environment Presets
204
+
205
+ ### Development
206
+ - Format: Colored console output
207
+ - Level: INFO
208
+ - Perfect for local development
209
+
210
+ ### Production
211
+ - Format: JSON (structured)
212
+ - Level: WARNING
213
+ - Optimized for log aggregation tools
214
+
215
+ ### Testing
216
+ - Format: Simple
217
+ - Level: INFO
218
+ - Minimal output for tests
219
+
220
+ ### Debug
221
+ - Format: Colored
222
+ - Level: DEBUG
223
+ - Maximum verbosity
224
+
225
+ ## Documentation
226
+
227
+ See [docs/usage.md](docs/usage.md) for complete documentation including:
228
+ - Advanced configuration
229
+ - Custom formatters
230
+ - Best practices
231
+ - Integration examples
232
+
233
+ ## Example
234
+
235
+ Run the example application:
236
+
237
+ ```bash
238
+ python log2fast_fastapi/example.py
239
+ ```
240
+
241
+ Then visit:
242
+ - http://localhost:8000/ - Root endpoint
243
+ - http://localhost:8000/users/123 - User endpoint
244
+ - http://localhost:8000/docs - API documentation
245
+
246
+ ## Testing
247
+
248
+ Run the test suite:
249
+
250
+ ```bash
251
+ python log2fast_fastapi/tests/test_logging.py
252
+ ```
253
+
254
+ ## Module Structure
255
+
256
+ ```
257
+ log2fast-fastapi/
258
+ ├── pyproject.toml # Package configuration
259
+ ├── MANIFEST.in # Additional files to include
260
+ ├── README.md # This file
261
+ ├── LICENSE # License file
262
+ ├── src/
263
+ │ └── log2fast_fastapi/
264
+ │ ├── __init__.py # Main exports
265
+ │ ├── __version__.py # Version information
266
+ │ ├── base.py # Core FastLogger class
267
+ │ ├── settings.py # Configuration with Pydantic
268
+ │ ├── formatters.py # Custom log formatters
269
+ │ └── middleware.py # FastAPI middleware
270
+ ├── docs/
271
+ │ ├── usage.md # Complete documentation
272
+ │ ├── file_management.md # File rotation guide (EN)
273
+ │ ├── file_management_es.md # File rotation guide (ES)
274
+ │ ├── logger_best_practices.md # Best practices
275
+ │ └── publishing.md # PyPI publishing guide
276
+ ├── examples/
277
+ │ ├── example.py # Basic example
278
+ │ ├── demo_features.py # Feature demonstrations
279
+ │ └── demo_rotation.py # Rotation examples
280
+ └── tests/
281
+ ├── test_logging.py # Test suite
282
+ └── test_new_features.py # Feature tests
283
+ ```
284
+
285
+ ## License
286
+
287
+ Same as parent project.
@@ -0,0 +1,232 @@
1
+ # log2fast-fastapi
2
+
3
+ 🚀 Advanced logging module for FastAPI with file rotation, colored output, and environment-based auto-configuration
4
+
5
+ > [!WARNING]
6
+ > **Internal Use Notice**
7
+ >
8
+ > This package is designed and maintained by the **Solautyc Team** for internal use. While it is publicly available, it may not work as expected in all environments or use cases outside of our specific infrastructure. We do not provide support or guarantees for external usage, and we are not responsible for any issues that may arise from using this package in other contexts.
9
+ >
10
+ > Use at your own risk. Contributions and feedback are welcome, but compatibility with external environments is not guaranteed.
11
+
12
+ ## Features
13
+
14
+ - 🎨 **Multiple Output Formats**: JSON (production), Colored (development), Structured (debugging), Simple (testing)
15
+ - 🌍 **Environment-Based Configuration**: Automatic setup for dev, test, prod, and debug
16
+ - 📦 **Module-Based Loggers**: Each module gets its own logger instance
17
+ - 🔄 **File Rotation**: Automatic log file rotation with configurable size
18
+ - 🔄 **Environment-Specific Logging**: Control which logs appear in which environments (prevent sensitive data leaks)
19
+ - 🚀 **FastAPI Integration**: Middleware for automatic request/response logging with unique request IDs
20
+ - 📊 **Structured Logging**: Add context data to any log message
21
+ - 📊 **Context Injection**: Support for request_id, user_id, and custom context data
22
+ - 🎯 **Zero Configuration**: Works out of the box with sensible defaults
23
+
24
+ ## 📚 Documentation
25
+
26
+ - **[Usage Guide](docs/usage.md)** - Comprehensive usage guide with examples
27
+ - **[File Management](docs/file_management.md)** - Complete guide on log rotation and storage (English)
28
+ - **[Gestión de Archivos](docs/file_management_es.md)** - Guía completa de rotación y almacenamiento (Español)
29
+ - **[Logger Best Practices](docs/logger_best_practices.md)** - Best practices for creating and naming loggers
30
+
31
+
32
+ ## Installation
33
+
34
+ ### From PyPI (Recommended)
35
+
36
+ ```bash
37
+ pip install log2fast-fastapi
38
+ ```
39
+
40
+ ### From Source
41
+
42
+ ```bash
43
+ # Clone the repository
44
+ git clone https://github.com/AngelDanielSanchezCastillo/log2fast-fastapi.git
45
+ cd log2fast-fastapi
46
+
47
+ # Install in development mode
48
+ pip install -e .
49
+
50
+ # Or install with dev dependencies
51
+ pip install -e ".[dev]"
52
+ ```
53
+
54
+
55
+ ## Quick Start
56
+
57
+ ### Basic Usage
58
+
59
+ ```python
60
+ from log2fast_fastapi import get_logger
61
+
62
+ logger = get_logger(__name__)
63
+
64
+ logger.info("Application started")
65
+ logger.warning("This is a warning")
66
+ logger.error("An error occurred")
67
+ ```
68
+
69
+ ### FastAPI Integration
70
+
71
+ ```python
72
+ from fastapi import FastAPI
73
+ from log2fast_fastapi import RequestLoggingMiddleware, get_logger
74
+
75
+ app = FastAPI()
76
+ app.add_middleware(RequestLoggingMiddleware)
77
+
78
+ logger = get_logger(__name__)
79
+
80
+ @app.get("/")
81
+ async def root():
82
+ logger.info("Root endpoint accessed")
83
+ return {"message": "Hello World"}
84
+ ```
85
+
86
+ ### Logging with Context
87
+
88
+ ```python
89
+ from log2fast_fastapi import get_logger
90
+
91
+ logger = get_logger(__name__)
92
+
93
+ logger.info(
94
+ "User logged in",
95
+ extra_data={
96
+ "user_id": "12345",
97
+ "ip_address": "192.168.1.1"
98
+ }
99
+ )
100
+ ```
101
+
102
+ ### Environment-Specific Logging (Prevent Sensitive Data Leaks!)
103
+
104
+ ```python
105
+ # Logs ONLY in development/debug (NOT in production)
106
+ logger.debug(
107
+ "Sensitive debug info",
108
+ extra_data={"password_hash": "...", "token": "..."},
109
+ only_in=["development", "debug"]
110
+ )
111
+
112
+ # Logs ONLY in production
113
+ logger.info(
114
+ "Performance metrics",
115
+ extra_data={"response_time": 120},
116
+ only_in=["production"]
117
+ )
118
+ ```
119
+
120
+ ## Configuration
121
+
122
+ **Simple: Just set the environment in `.env`**
123
+
124
+ ```bash
125
+ # That's it! Format and level auto-configure
126
+ LOG_ENVIRONMENT=production
127
+ ```
128
+
129
+ Auto-configuration by environment:
130
+
131
+ | Environment | Auto Level | Auto Format |
132
+ |------------|-----------|-------------|
133
+ | `development` | INFO | colored |
134
+ | `production` | WARNING | json |
135
+ | `testing` | INFO | simple |
136
+ | `debug` | DEBUG | colored |
137
+
138
+ **Optional: Override defaults**
139
+
140
+
141
+ ```bash
142
+ # Optional: Override auto-configuration
143
+ LOG_LEVEL=DEBUG
144
+ LOG_FORMAT=json
145
+ LOG_FILE_SETTINGS__ENABLED=true
146
+ ```
147
+
148
+ ## Environment Presets
149
+
150
+ ### Development
151
+ - Format: Colored console output
152
+ - Level: INFO
153
+ - Perfect for local development
154
+
155
+ ### Production
156
+ - Format: JSON (structured)
157
+ - Level: WARNING
158
+ - Optimized for log aggregation tools
159
+
160
+ ### Testing
161
+ - Format: Simple
162
+ - Level: INFO
163
+ - Minimal output for tests
164
+
165
+ ### Debug
166
+ - Format: Colored
167
+ - Level: DEBUG
168
+ - Maximum verbosity
169
+
170
+ ## Documentation
171
+
172
+ See [docs/usage.md](docs/usage.md) for complete documentation including:
173
+ - Advanced configuration
174
+ - Custom formatters
175
+ - Best practices
176
+ - Integration examples
177
+
178
+ ## Example
179
+
180
+ Run the example application:
181
+
182
+ ```bash
183
+ python log2fast_fastapi/example.py
184
+ ```
185
+
186
+ Then visit:
187
+ - http://localhost:8000/ - Root endpoint
188
+ - http://localhost:8000/users/123 - User endpoint
189
+ - http://localhost:8000/docs - API documentation
190
+
191
+ ## Testing
192
+
193
+ Run the test suite:
194
+
195
+ ```bash
196
+ python log2fast_fastapi/tests/test_logging.py
197
+ ```
198
+
199
+ ## Module Structure
200
+
201
+ ```
202
+ log2fast-fastapi/
203
+ ├── pyproject.toml # Package configuration
204
+ ├── MANIFEST.in # Additional files to include
205
+ ├── README.md # This file
206
+ ├── LICENSE # License file
207
+ ├── src/
208
+ │ └── log2fast_fastapi/
209
+ │ ├── __init__.py # Main exports
210
+ │ ├── __version__.py # Version information
211
+ │ ├── base.py # Core FastLogger class
212
+ │ ├── settings.py # Configuration with Pydantic
213
+ │ ├── formatters.py # Custom log formatters
214
+ │ └── middleware.py # FastAPI middleware
215
+ ├── docs/
216
+ │ ├── usage.md # Complete documentation
217
+ │ ├── file_management.md # File rotation guide (EN)
218
+ │ ├── file_management_es.md # File rotation guide (ES)
219
+ │ ├── logger_best_practices.md # Best practices
220
+ │ └── publishing.md # PyPI publishing guide
221
+ ├── examples/
222
+ │ ├── example.py # Basic example
223
+ │ ├── demo_features.py # Feature demonstrations
224
+ │ └── demo_rotation.py # Rotation examples
225
+ └── tests/
226
+ ├── test_logging.py # Test suite
227
+ └── test_new_features.py # Feature tests
228
+ ```
229
+
230
+ ## License
231
+
232
+ Same as parent project.
@@ -0,0 +1,149 @@
1
+ # ============================================
2
+ # LOG2FAST_FASTAPI - Configuración de Logging
3
+ # ============================================
4
+
5
+ # ===== CONFIGURACIÓN BÁSICA (REQUERIDA) =====
6
+
7
+ # Ambiente de ejecución (determina auto-configuración)
8
+ # Opciones: development, production, testing, debug
9
+ LOG_ENVIRONMENT=development
10
+
11
+
12
+ # ===== CONFIGURACIÓN OPCIONAL (OVERRIDES) =====
13
+
14
+ # Nivel de log (opcional - se auto-configura según ambiente)
15
+ # Opciones: DEBUG, INFO, WARNING, ERROR, CRITICAL
16
+ # LOG_LEVEL=INFO
17
+
18
+ # Formato de log (opcional - se auto-configura según ambiente)
19
+ # Opciones: json, colored, structured, simple
20
+ # LOG_FORMAT=colored
21
+
22
+
23
+ # ===== CONFIGURACIÓN DE CONSOLA =====
24
+
25
+ # Habilitar logging en consola
26
+ LOG_CONSOLE_ENABLED=true
27
+
28
+
29
+ # ===== CONFIGURACIÓN DE ARCHIVOS =====
30
+
31
+ # Habilitar logging en archivos
32
+ LOG_FILE_SETTINGS__ENABLED=true
33
+
34
+ # Directorio donde guardar los logs (relativo al proyecto o absoluto)
35
+ # Default: logs/ (en la raíz del proyecto)
36
+ LOG_FILE_SETTINGS__DIRECTORY=logs
37
+
38
+ # Estrategia de rotación de archivos
39
+ # Opciones: time (por tiempo), size (por tamaño)
40
+ # Default: time (diario a medianoche, 31 días de backups)
41
+ LOG_FILE_SETTINGS__ROTATION_STRATEGY=time
42
+
43
+
44
+ # ===== ROTACIÓN POR TIEMPO (cuando ROTATION_STRATEGY=time) =====
45
+
46
+ # Cuándo rotar los archivos
47
+ # Opciones:
48
+ # - midnight: A medianoche (default)
49
+ # - H: Cada hora
50
+ # - D: Cada día
51
+ # - W0-W6: Cada semana (W0=Lunes, W6=Domingo)
52
+ LOG_FILE_SETTINGS__WHEN=midnight
53
+
54
+ # Intervalo de rotación (usado con 'when')
55
+ # Ejemplos:
56
+ # - 1 con when=midnight: Diario
57
+ # - 2 con when=midnight: Cada 2 días
58
+ # - 1 con when=H: Cada hora
59
+ LOG_FILE_SETTINGS__INTERVAL=1
60
+
61
+ # Número de archivos de backup a mantener
62
+ # Default: 31 (31 días de logs si es diario)
63
+ LOG_FILE_SETTINGS__BACKUP_COUNT=31
64
+
65
+
66
+ # ===== ROTACIÓN POR TAMAÑO (cuando ROTATION_STRATEGY=size) =====
67
+
68
+ # Tamaño máximo por archivo en bytes
69
+ # Ejemplos:
70
+ # - 10485760 = 10MB (default)
71
+ # - 52428800 = 50MB
72
+ # - 104857600 = 100MB
73
+ # LOG_FILE_SETTINGS__MAX_BYTES=10485760
74
+
75
+ # Número de archivos de backup a mantener (para rotación por tamaño)
76
+ # LOG_FILE_SETTINGS__BACKUP_COUNT=5
77
+
78
+
79
+ # ===== CONFIGURACIÓN DE NOMBRES DE ARCHIVO =====
80
+
81
+ # Patrón para nombres de archivos
82
+ # Variables disponibles: {module}, {environment}, {logger}
83
+ # Default: {module}_{environment}.log
84
+ # Ejemplos:
85
+ # - app_{environment}.log
86
+ # - {logger}_{environment}.log (útil con per_module_files)
87
+ LOG_FILE_SETTINGS__FILENAME_PATTERN={module}_{environment}.log
88
+
89
+ # Crear archivos separados por módulo
90
+ # Si es true, cada logger (módulo) tendrá su propio archivo
91
+ # Ejemplo: oauth2fast_fastapi_development.log, app_api_development.log
92
+ LOG_FILE_SETTINGS__PER_MODULE_FILES=false
93
+
94
+
95
+ # ===== CONFIGURACIÓN DE REQUESTS (FastAPI Middleware) =====
96
+
97
+ # Habilitar logging de requests HTTP
98
+ LOG_LOG_REQUESTS=true
99
+
100
+ # Incluir body del request en logs (cuidado con PII)
101
+ LOG_LOG_REQUEST_BODY=false
102
+
103
+ # Incluir body del response en logs (cuidado con PII)
104
+ LOG_LOG_RESPONSE_BODY=false
105
+
106
+
107
+ # ===== CONFIGURACIÓN DE MÓDULO =====
108
+
109
+ # Nombre del módulo principal (usado en nombres de archivo)
110
+ # Default: app
111
+ LOG_MODULE_NAME=iso_solautyc
112
+
113
+
114
+ # ============================================
115
+ # EJEMPLOS DE CONFIGURACIÓN POR AMBIENTE
116
+ # ============================================
117
+
118
+ # --- DESARROLLO LOCAL ---
119
+ # LOG_ENVIRONMENT=development
120
+ # LOG_FILE_SETTINGS__ROTATION_STRATEGY=time
121
+ # LOG_FILE_SETTINGS__WHEN=midnight
122
+ # LOG_FILE_SETTINGS__BACKUP_COUNT=7
123
+ # Resultado: Logs diarios, mantiene 7 días
124
+
125
+ # --- PRODUCCIÓN ---
126
+ # LOG_ENVIRONMENT=production
127
+ # LOG_FILE_SETTINGS__ROTATION_STRATEGY=time
128
+ # LOG_FILE_SETTINGS__WHEN=midnight
129
+ # LOG_FILE_SETTINGS__BACKUP_COUNT=31
130
+ # Resultado: Logs diarios en JSON, mantiene 31 días
131
+
132
+ # --- DEBUGGING ---
133
+ # LOG_ENVIRONMENT=debug
134
+ # LOG_FILE_SETTINGS__ROTATION_STRATEGY=size
135
+ # LOG_FILE_SETTINGS__MAX_BYTES=52428800
136
+ # LOG_FILE_SETTINGS__BACKUP_COUNT=3
137
+ # Resultado: Logs cuando llega a 50MB, mantiene 3 archivos
138
+
139
+ # --- TESTING ---
140
+ # LOG_ENVIRONMENT=testing
141
+ # LOG_FILE_SETTINGS__ENABLED=false
142
+ # Resultado: Solo logs en consola, sin archivos
143
+
144
+ # --- LOGS POR MÓDULO ---
145
+ # LOG_FILE_SETTINGS__PER_MODULE_FILES=true
146
+ # Resultado: Cada módulo tiene su archivo
147
+ # - oauth2fast_fastapi_routers_auth_development.log
148
+ # - app_services_user_development.log
149
+ # - etc.