Skip to content

Commit

Permalink
feat: bump libraries and fix log
Browse files Browse the repository at this point in the history
  • Loading branch information
rivamarco committed Jul 25, 2024
1 parent d59f33c commit d1c4f78
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 77 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ In order to use a real AWS instead of Minio it is necessary to modify the enviro
To completely clean up the environment we can use [docker compose](https://docs.docker.com/reference/cli/docker/compose/down/)

```bash
docker compose --profile ui --profile k9s down -v --remove-orphans
docker compose --profile ui --profile k9s --profile init-data down -v --remove-orphans
```

To remove everything including container images:

```bash
docker compose --profile ui --profile k9s down -v --remove-orphans --rmi all
docker compose --profile ui --profile k9s --profile init-data down -v --remove-orphans --rmi all
```

## 📖 Documentation
Expand Down
35 changes: 28 additions & 7 deletions api/app/core/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,20 @@ class LogConfig(BaseSettings):

model_config = SettingsConfigDict(env_file=f'{base_dir}/logger.conf')
logger_name: str = 'radicalbit-ai-monitoring'
log_format: str = '%(levelprefix)s | %(asctime)s | %(message)s'
log_format: str = '%(levelname)s | %(asctime)s | %(message)s'
log_level: str = 'DEBUG'
counter_log_threshold: int = 99
time_log_threshold: int = 59

# logger dictConfig
version: int = 1
disable_existing_loggers: bool = False

formatters: Dict = {
'default': {
'()': 'uvicorn.logging.DefaultFormatter',
'fmt': log_format,
'format': log_format,
'datefmt': '%Y-%m-%d %H:%M:%S',
},
'access': {
'format': log_format,
'datefmt': '%Y-%m-%d %H:%M:%S',
},
}
Expand All @@ -95,15 +97,34 @@ class LogConfig(BaseSettings):
'class': 'logging.StreamHandler',
'stream': 'ext://sys.stderr',
},
'access': {
'formatter': 'access',
'class': 'logging.StreamHandler',
'stream': 'ext://sys.stdout',
'filters': ['healthcheck_filter'],
},
}
loggers: Dict = {
logger_name: {'handlers': ['default'], 'level': log_level},
logger_name: {
'handlers': ['default'],
'level': log_level.upper(),
'propagate': False,
},
'uvicorn.error': {
'handlers': ['default'],
'level': log_level.upper(),
'propagate': False,
},
'uvicorn.access': {'handlers': ['default'], 'level': log_level},
'uvicorn.access': {
'handlers': ['access'],
'level': log_level.upper(),
'propagate': False,
},
'root': {
'handlers': ['default'],
'level': log_level.upper(),
'propagate': False,
},
}


Expand Down
2 changes: 2 additions & 0 deletions api/app/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from contextlib import asynccontextmanager
import logging
from logging.config import dictConfig

import boto3
from fastapi import FastAPI
Expand Down Expand Up @@ -35,6 +36,7 @@
from app.services.model_service import ModelService
from app.services.spark_k8s_service import SparkK8SService

dictConfig(get_config().log_config.model_dump())
logger = logging.getLogger(get_config().log_config.logger_name)

database = Database(get_config().db_config)
Expand Down
Loading

0 comments on commit d1c4f78

Please sign in to comment.