See the License for the specific language governing permissions and limitations under the License. """ import logging from fastapi import APIRouter, HTTPException from loguru import logger from starlette.datastructures import Headers from starlette.status import HTTP_404_NOT_FOUND from api.utils import create_request_coroutine from core.config import REFGET_SERVER_URL_LIST from core.logging import InterceptHandler logging.getLogger().handlers = [InterceptHandler()] router = APIRouter() @router.get("/{checksum}", name="sequence") async def get_sequence(checksum: str, start: int = 0, end: int = 0, accept: str = ""): """ Return Refget sequence based on checksum value. str start: Start point of the sequence defined in checksum. str end: End point of the sequence defined in checksum. """ headers = Headers()
cast=int, default=10) MIN_CONNECTIONS_COUNT: int = config("MIN_CONNECTIONS_COUNT", cast=int, default=10) SECRET_KEY: Secret = config("SECRET_KEY", cast=Secret) PROJECT_NAME: str = config("PROJECT_NAME", default="FastAPI example application") ALLOWED_HOSTS: List[str] = config( "ALLOWED_HOSTS", cast=CommaSeparatedStrings, default="", ) # Template dir TEMPLATE_DIR = config('TEMPLATE_DIR', default='templates') # logging configuration LOGGING_LEVEL = logging.DEBUG if DEBUG else logging.INFO LOGGERS = ("uvicorn.asgi", "uvicorn.access") # intercept standard logging messages toward your Loguru sinks logging.getLogger().handlers = [InterceptHandler()] for logger_name in LOGGERS: logging_logger = logging.getLogger(logger_name) logging_logger.handlers = [InterceptHandler(level=LOGGING_LEVEL)] logger.configure(handlers=[{"sink": sys.stderr, "level": LOGGING_LEVEL}])
import logging import sys from core.logging import InterceptHandler from loguru import logger from starlette.config import Config config = Config(".env") API_PREFIX = "" VERSION = "0.1.0" DEBUG: bool = config("DEBUG", cast=bool, default=False) MAX_CONNECTIONS_COUNT: int = config("MAX_CONNECTIONS_COUNT", cast=int, default=10) MIN_CONNECTIONS_COUNT: int = config("MIN_CONNECTIONS_COUNT", cast=int, default=10) PROJECT_NAME: str = config("PROJECT_NAME", default="PrometheusCustomIPCounter") # logging configuration LOGGING_LEVEL = logging.DEBUG if DEBUG else logging.INFO logging.basicConfig(handlers=[InterceptHandler(level=LOGGING_LEVEL)], level=LOGGING_LEVEL) logger.configure(handlers=[{"sink": sys.stderr, "level": LOGGING_LEVEL}])