|
| 1 | +# Standardize Logging Format Across All Python Files |
| 2 | + |
| 3 | +## Issue Description |
| 4 | + |
| 5 | +Currently, Python files in this repository use inconsistent logging formats. We need to standardize all logging configurations to use the following format specifier: |
| 6 | + |
| 7 | +```python |
| 8 | +format="%(asctime)s,p%(process)s,{%(filename)s:%(lineno)d},%(levelname)s,%(message)s" |
| 9 | +``` |
| 10 | + |
| 11 | +## Current State Analysis |
| 12 | + |
| 13 | +### Root Logger Configuration Files (Entry Points): |
| 14 | + |
| 15 | +1. **`registry/main.py:44-47`** - **Registry Application Entry Point** |
| 16 | + - **Current format**: `'%(asctime)s.%(msecs)03d - PID:%(process)d - %(filename)s:%(lineno)d - %(name)s - %(levelname)s - %(message)s'` |
| 17 | + - **Scope**: Configures root logger, affects all registry/* modules |
| 18 | + - **Status**: ❌ Needs update (different format structure) |
| 19 | + |
| 20 | +2. **`auth_server/server.py:31-35`** - **Auth Server Entry Point** |
| 21 | + - **Current format**: `"[%(asctime)s] p%(process)s {%(filename)s:%(lineno)d} %(levelname)s - %(message)s"` |
| 22 | + - **Scope**: Configures root logger via basicConfig, affects auth server modules |
| 23 | + - **Status**: ❌ Needs update (brackets around timestamp, missing comma separators) |
| 24 | + |
| 25 | +3. **`agents/agent.py:71-75`** - **Agent Entry Point** |
| 26 | + - **Current format**: `"%(asctime)s,p%(process)s,{%(filename)s:%(lineno)d},%(levelname)s,%(message)s"` |
| 27 | + - **Scope**: Configures root logger via basicConfig, affects agent modules |
| 28 | + - **Status**: ✅ Already compliant |
| 29 | + |
| 30 | +### MCP Server Entry Points (servers/ directory): |
| 31 | + |
| 32 | +4. **`servers/mcpgw/server.py:24-28`** - **MCP Gateway Server** |
| 33 | + - **Current format**: `'%(asctime)s.%(msecs)03d - PID:%(process)d - %(filename)s:%(lineno)d - %(name)s - %(levelname)s - %(message)s'` |
| 34 | + - **Scope**: Standalone MCP server |
| 35 | + - **Status**: ❌ Needs update (different format structure, same as registry/main.py) |
| 36 | + |
| 37 | +5. **`servers/currenttime/server.py:16-20`** - **Current Time MCP Server** |
| 38 | + - **Current format**: `'%(asctime)s.%(msecs)03d - PID:%(process)d - %(filename)s:%(lineno)d - %(name)s - %(levelname)s - %(message)s'` |
| 39 | + - **Scope**: Standalone MCP server |
| 40 | + - **Status**: ❌ Needs update (different format structure, same as registry/main.py) |
| 41 | + |
| 42 | +6. **`servers/fininfo/server.py:17-21`** - **Financial Info MCP Server** |
| 43 | + - **Current format**: `'%(asctime)s.%(msecs)03d - PID:%(process)d - %(filename)s:%(lineno)d - %(name)s - %(levelname)s - %(message)s'` |
| 44 | + - **Scope**: Standalone MCP server |
| 45 | + - **Status**: ❌ Needs update (different format structure, same as registry/main.py) |
| 46 | + |
| 47 | +7. **`servers/realserverfaketools/server.py:18-22`** - **Fake Tools MCP Server** |
| 48 | + - **Current format**: `'%(asctime)s.%(msecs)03d - PID:%(process)d - %(filename)s:%(lineno)d - %(name)s - %(levelname)s - %(message)s'` |
| 49 | + - **Scope**: Standalone MCP server |
| 50 | + - **Status**: ❌ Needs update (different format structure, same as registry/main.py) |
| 51 | + |
| 52 | +### Files That Inherit Logging Format (No Changes Needed): |
| 53 | + |
| 54 | +8. **`registry/auth/routes.py:13`** |
| 55 | + - **Current**: Uses `logging.getLogger(__name__)` - inherits from registry/main.py |
| 56 | + - **Status**: ✅ Will inherit correct format once main.py is updated |
| 57 | + |
| 58 | +9. **`registry/search/service.py:14`** |
| 59 | + - **Current**: Uses `logging.getLogger(__name__)` - inherits from registry/main.py |
| 60 | + - **Status**: ✅ Will inherit correct format once main.py is updated |
| 61 | + |
| 62 | +10. **`registry/health/routes.py:7`** |
| 63 | + - **Current**: Uses `logging.getLogger(__name__)` - inherits from registry/main.py |
| 64 | + - **Status**: ✅ Will inherit correct format once main.py is updated |
| 65 | + |
| 66 | +11. **`registry/core/nginx_service.py:9`** |
| 67 | + - **Current**: Uses `logging.getLogger(__name__)` - inherits from registry/main.py |
| 68 | + - **Status**: ✅ Will inherit correct format once main.py is updated |
| 69 | + |
| 70 | +### Files Without Logging: |
| 71 | + |
| 72 | +12. **`registry/core/schemas.py`** |
| 73 | + - **Status**: ✅ No logging configuration needed (data models only) |
| 74 | + |
| 75 | +13. **`registry/core/config.py`** |
| 76 | + - **Status**: ✅ No logging configuration needed (configuration only) |
| 77 | + |
| 78 | +## Implementation Requirements |
| 79 | + |
| 80 | +### Target Format Specification: |
| 81 | +```python |
| 82 | +format="%(asctime)s,p%(process)s,{%(filename)s:%(lineno)d},%(levelname)s,%(message)s" |
| 83 | +``` |
| 84 | + |
| 85 | +### Expected Output Format: |
| 86 | +``` |
| 87 | +2025-06-15 17:48:37,p12345,{server.py:123},INFO,Server started successfully |
| 88 | +``` |
| 89 | + |
| 90 | +## Files Requiring Changes Summary: |
| 91 | + |
| 92 | +**Total files needing updates: 6** (Entry points only) |
| 93 | + |
| 94 | +### Main Application Entry Points: |
| 95 | +1. `registry/main.py` - Format modification (affects all registry/* modules) |
| 96 | +2. `auth_server/server.py` - Format modification (affects auth server modules) |
| 97 | + |
| 98 | +### MCP Server Entry Points: |
| 99 | +3. `servers/mcpgw/server.py` - Format modification (standalone server) |
| 100 | +4. `servers/currenttime/server.py` - Format modification (standalone server) |
| 101 | +5. `servers/fininfo/server.py` - Format modification (standalone server) |
| 102 | +6. `servers/realserverfaketools/server.py` - Format modification (standalone server) |
| 103 | + |
| 104 | +**Already Compliant:** |
| 105 | +- `agents/agent.py` - Already uses target format ✅ |
| 106 | + |
| 107 | +**Note**: Files using `logging.getLogger(__name__)` will automatically inherit the correct format once their respective entry points are updated, thanks to Python's logging hierarchy. The MCP servers in the `servers/` directory are standalone applications that each configure their own logging. |
| 108 | + |
| 109 | +## Benefits |
| 110 | + |
| 111 | +- **Consistency**: Uniform log format across all components |
| 112 | +- **Parsing**: Easier automated log parsing and analysis |
| 113 | +- **Debugging**: Consistent structure for troubleshooting |
| 114 | +- **Monitoring**: Standardized format for log aggregation tools |
| 115 | + |
| 116 | +## Acceptance Criteria |
| 117 | + |
| 118 | +- [ ] All Python files use the standardized logging format |
| 119 | +- [ ] Existing functionality remains unchanged |
| 120 | +- [ ] Log output follows the expected format pattern |
| 121 | +- [ ] No breaking changes to current logging behavior |
| 122 | + |
| 123 | +## Labels |
| 124 | +`enhancement`, `logging`, `maintenance` |
| 125 | + |
| 126 | +## Priority |
| 127 | +Medium |
0 commit comments