Skip to content

Commit 8f46f33

Browse files
authored
Merge pull request #34 from agentic-community/fix/standardize-logging-format-issue-33
Standardize logging format across all Python files
2 parents 94909bb + 99ed32c commit 8f46f33

File tree

9 files changed

+256
-14
lines changed

9 files changed

+256
-14
lines changed

GITHUB_ISSUE_CONTENT.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
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
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
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`](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`](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`](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`](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`](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`](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`](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+
4. **[`registry/auth/routes.py`](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+
5. **[`registry/search/service.py`](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+
6. **[`registry/health/routes.py`](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+
7. **[`registry/core/nginx_service.py`](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+
8. **[`registry/core/schemas.py`](registry/core/schemas.py)**
73+
- **Status**: ✅ No logging configuration needed (data models only)
74+
75+
9. **[`registry/core/config.py`](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

agents/agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
logging.basicConfig(
7272
level=logging.INFO, # Set the log level to INFO
7373
# Define log message format
74-
format="[%(asctime)s] p%(process)s {%(filename)s:%(lineno)d} %(levelname)s - %(message)s",
74+
format="%(asctime)s,p%(process)s,{%(filename)s:%(lineno)d},%(levelname)s,%(message)s",
7575
)
7676

7777
# Get logger

auth_server/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
logging.basicConfig(
3232
level=logging.INFO, # Set the log level to INFO
3333
# Define log message format
34-
format="[%(asctime)s] p%(process)s {%(filename)s:%(lineno)d} %(levelname)s - %(message)s",
34+
format="%(asctime)s,p%(process)s,{%(filename)s:%(lineno)d},%(levelname)s,%(message)s",
3535
)
3636
logger = logging.getLogger(__name__)
3737
# Load scopes configuration

registry/main.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,11 @@ def setup_logging():
4242

4343
# Create formatters
4444
file_formatter = logging.Formatter(
45-
'%(asctime)s.%(msecs)03d - PID:%(process)d - %(filename)s:%(lineno)d - %(name)s - %(levelname)s - %(message)s',
46-
datefmt='%Y-%m-%d %H:%M:%S'
45+
'%(asctime)s,p%(process)s,{%(filename)s:%(lineno)d},%(levelname)s,%(message)s'
4746
)
4847

4948
console_formatter = logging.Formatter(
50-
'%(asctime)s.%(msecs)03d - %(name)s - %(levelname)s - %(message)s',
51-
datefmt='%Y-%m-%d %H:%M:%S'
49+
'%(asctime)s,p%(process)s,{%(filename)s:%(lineno)d},%(levelname)s,%(message)s'
5250
)
5351

5452
# Get root logger

servers/currenttime/server.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
# Configure logging
1616
logging.basicConfig(
1717
level=logging.INFO,
18-
format='%(asctime)s.%(msecs)03d - PID:%(process)d - %(filename)s:%(lineno)d - %(name)s - %(levelname)s - %(message)s',
19-
datefmt='%Y-%m-%d %H:%M:%S'
18+
format='%(asctime)s,p%(process)s,{%(filename)s:%(lineno)d},%(levelname)s,%(message)s'
2019
)
2120
logger = logging.getLogger(__name__)
2221

servers/fininfo/server.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
# Configure logging
1717
logging.basicConfig(
1818
level=logging.DEBUG,
19-
format='%(asctime)s.%(msecs)03d - PID:%(process)d - %(filename)s:%(lineno)d - %(name)s - %(levelname)s - %(message)s',
20-
datefmt='%Y-%m-%d %H:%M:%S'
19+
format='%(asctime)s,p%(process)s,{%(filename)s:%(lineno)d},%(levelname)s,%(message)s'
2120
)
2221
logger = logging.getLogger(__name__)
2322

servers/mcpgw/server.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
# Configure logging
2424
logging.basicConfig(
2525
level=logging.INFO,
26-
format='%(asctime)s.%(msecs)03d - PID:%(process)d - %(filename)s:%(lineno)d - %(name)s - %(levelname)s - %(message)s',
27-
datefmt='%Y-%m-%d %H:%M:%S'
26+
format='%(asctime)s,p%(process)s,{%(filename)s:%(lineno)d},%(levelname)s,%(message)s'
2827
)
2928
logger = logging.getLogger(__name__)
3029

servers/realserverfaketools/server.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
# Configure logging
1818
logging.basicConfig(
1919
level=logging.INFO,
20-
format='%(asctime)s.%(msecs)03d - PID:%(process)d - %(filename)s:%(lineno)d - %(name)s - %(levelname)s - %(message)s',
21-
datefmt='%Y-%m-%d %H:%M:%S'
20+
format='%(asctime)s,p%(process)s,{%(filename)s:%(lineno)d},%(levelname)s,%(message)s'
2221
)
2322
logger = logging.getLogger(__name__)
2423

0 commit comments

Comments
 (0)