Skip to content

Commit 1bfc651

Browse files
chouzzsng-asyncfuncgemini-code-assist[bot]
authored
fix: add IgnoreLogChangeDetectedFilter for logging to ignore changes (#253)
* Revert "fix: move log file to parent directory to avoid infinite logging loop (#250)" This reverts commit 30c400c. * fix: add IgnoreLogChangeDetectedFilter for logging to ignore changes of log file * Update api/logging_config.py Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --------- Co-authored-by: Sheing [ASYNCFUNC] <[email protected]> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 30c400c commit 1bfc651

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ develop-eggs/
2121
dist/
2222
downloads/
2323
eggs/
24-
logs/
24+
api/logs/
2525
.eggs/
2626
lib/
2727
lib64/

api/logging_config.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
import os
33
from pathlib import Path
44

5+
class IgnoreLogChangeDetectedFilter(logging.Filter):
6+
def filter(self, record: logging.LogRecord):
7+
return "Detected file change in" not in record.getMessage()
58

69
def setup_logging(format: str = None):
710
"""
@@ -10,8 +13,7 @@ def setup_logging(format: str = None):
1013
Ensures log directory exists, and configures both file and console handlers.
1114
"""
1215
# Determine log directory and default file path
13-
# base_dir is now the workspace root
14-
base_dir = Path(__file__).resolve().parent.parent
16+
base_dir = Path(__file__).parent
1517
log_dir = base_dir / "logs"
1618
log_dir.mkdir(parents=True, exist_ok=True)
1719
default_log_file = log_dir / "application.log"
@@ -42,6 +44,10 @@ def setup_logging(format: str = None):
4244
],
4345
force=True
4446
)
47+
48+
# Ignore log file's change detection
49+
for handler in logging.getLogger().handlers:
50+
handler.addFilter(IgnoreLogChangeDetectedFilter())
4551

4652
# Initial debug message to confirm configuration
4753
logger = logging.getLogger(__name__)

api/main.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,5 @@
5353
"api.api:app",
5454
host="0.0.0.0",
5555
port=port,
56-
reload=is_development,
57-
reload_dirs=["api"] if is_development else None
56+
reload=is_development
5857
)

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ services:
1515
- NODE_ENV=production
1616
- SERVER_BASE_URL=http://localhost:${PORT:-8001}
1717
- LOG_LEVEL=${LOG_LEVEL:-INFO}
18-
- LOG_FILE_PATH=${LOG_FILE_PATH:-logs/application.log}
18+
- LOG_FILE_PATH=${LOG_FILE_PATH:-api/logs/application.log}
1919
volumes:
2020
- ~/.adalflow:/root/.adalflow # Persist repository and embedding data
21-
- ./logs:/app/logs # Persist log files across container restarts
21+
- ./api/logs:/app/api/logs # Persist log files across container restarts
2222
# Resource limits for docker-compose up (not Swarm mode)
2323
mem_limit: 6g
2424
mem_reservation: 2g

0 commit comments

Comments
 (0)