[logging] use logger from halfapi.logging

This commit is contained in:
Maxime Alves LIRMM 2021-11-02 15:15:07 +01:00
parent 00c7b5caf4
commit ad9bd45ba0
12 changed files with 13 additions and 24 deletions

View File

@ -3,7 +3,6 @@
cli/domain.py Defines the "halfapi domain" cli commands cli/domain.py Defines the "halfapi domain" cli commands
""" """
# builtins # builtins
import logging
import sys import sys
import click import click
@ -16,7 +15,7 @@ from ..lib.schemas import schema_dict_dom
from ..lib.routes import api_routes from ..lib.routes import api_routes
logger = logging.getLogger('halfapi') from ..logging import logger
################# #################
# domain create # # domain create #

View File

@ -5,7 +5,6 @@ cli/init.py Defines the "halfapi init" cli commands
Helps the user to create a new project Helps the user to create a new project
""" """
# builtins # builtins
import logging
import os import os
import sys import sys
import re import re
@ -17,7 +16,7 @@ from ..conf import CONF_DIR
from .cli import cli from .cli import cli
logger = logging.getLogger('halfapi') from ..logging import logger
TMPL_HALFAPI_ETC = """[project] TMPL_HALFAPI_ETC = """[project]
name = {project} name = {project}

View File

@ -2,14 +2,12 @@
""" """
Base ACL module that contains generic functions for domains ACL Base ACL module that contains generic functions for domains ACL
""" """
import logging
from functools import wraps from functools import wraps
from json import JSONDecodeError from json import JSONDecodeError
from starlette.authentication import UnauthenticatedUser from starlette.authentication import UnauthenticatedUser
from starlette.exceptions import HTTPException from starlette.exceptions import HTTPException
from ..logging import logger
logger = logging.getLogger('uvicorn.asgi')
def public(*args, **kwargs) -> bool: def public(*args, **kwargs) -> bool:
"Unlimited access" "Unlimited access"

View File

@ -8,7 +8,6 @@ import re
import sys import sys
import importlib import importlib
import inspect import inspect
import logging
from types import ModuleType, FunctionType from types import ModuleType, FunctionType
from typing import Coroutine, Generator from typing import Coroutine, Generator
from typing import Dict, List, Tuple, Iterator from typing import Dict, List, Tuple, Iterator
@ -20,7 +19,7 @@ from halfapi.lib.responses import ORJSONResponse
from halfapi.lib.router import read_router from halfapi.lib.router import read_router
from halfapi.lib.constants import VERBS from halfapi.lib.constants import VERBS
logger = logging.getLogger("uvicorn.asgi") from ..logging import logger
class MissingAclError(Exception): class MissingAclError(Exception):
pass pass

View File

@ -1,15 +1,13 @@
""" """
DomainMiddleware DomainMiddleware
""" """
import logging
from starlette.datastructures import URL from starlette.datastructures import URL
from starlette.middleware.base import (BaseHTTPMiddleware, from starlette.middleware.base import (BaseHTTPMiddleware,
RequestResponseEndpoint) RequestResponseEndpoint)
from starlette.requests import Request from starlette.requests import Request
from starlette.responses import Response from starlette.responses import Response
logger = logging.getLogger('uvicorn.asgi') from ..logging import logger
class DomainMiddleware(BaseHTTPMiddleware): class DomainMiddleware(BaseHTTPMiddleware):
""" """

View File

@ -12,7 +12,6 @@ Raises:
from os import environ from os import environ
import typing import typing
import logging
from uuid import UUID from uuid import UUID
import jwt import jwt
@ -22,7 +21,7 @@ from starlette.authentication import (
from starlette.requests import HTTPConnection from starlette.requests import HTTPConnection
from starlette.exceptions import HTTPException from starlette.exceptions import HTTPException
logger = logging.getLogger('uvicorn.error') from ..logging import logger
SECRET=None SECRET=None
try: try:

View File

@ -15,7 +15,6 @@ Exception :
""" """
from datetime import datetime from datetime import datetime
from functools import partial, wraps from functools import partial, wraps
import logging
from typing import Callable, List, Dict, Generator, Tuple from typing import Callable, List, Dict, Generator, Tuple
from types import ModuleType, FunctionType from types import ModuleType, FunctionType
@ -27,8 +26,7 @@ from starlette.responses import Response, PlainTextResponse
from halfapi.lib.domain import gen_router_routes, domain_acls from halfapi.lib.domain import gen_router_routes, domain_acls
from ..conf import DOMAINSDICT from ..conf import DOMAINSDICT
from ..logging import logger
logger = logging.getLogger('uvicorn.asgi')
class DomainNotFoundError(Exception): class DomainNotFoundError(Exception):
""" Exception when a domain is not importable """ Exception when a domain is not importable

View File

@ -11,17 +11,16 @@ Constant :
""" """
import os import os
import logging
from typing import Dict, Coroutine from typing import Dict, Coroutine
from types import ModuleType from types import ModuleType
from starlette.schemas import SchemaGenerator from starlette.schemas import SchemaGenerator
from .. import __version__ from .. import __version__
from ..logging import logger
from .routes import gen_starlette_routes, api_routes, api_acls from .routes import gen_starlette_routes, api_routes, api_acls
from .responses import ORJSONResponse from .responses import ORJSONResponse
logger = logging.getLogger('uvicorn.asgi')
SCHEMAS = SchemaGenerator( SCHEMAS = SchemaGenerator(
{"openapi": "3.0.0", "info": {"title": "HalfAPI", "version": __version__}} {"openapi": "3.0.0", "info": {"title": "HalfAPI", "version": __version__}}
) )

View File

@ -9,7 +9,7 @@ import logging
from timing_asgi import TimingClient from timing_asgi import TimingClient
logger = logging.getLogger('uvicorn.asgi') from ..logging import logger
class HTimingClient(TimingClient): class HTimingClient(TimingClient):
""" Used to redefine TimingClient.timing """ Used to redefine TimingClient.timing

View File

@ -28,4 +28,4 @@ def config_logging(level=logging.INFO):
logging.getLogger('uvicorn.error').propagate = True logging.getLogger('uvicorn.error').propagate = True
config_logging() config_logging()
logger = logging.getLogger('uvicorn.asgi') logger = logging.getLogger()

View File

@ -23,7 +23,8 @@ from halfapi.cli.init import init, format_halfapi_etc
from halfapi.cli.domain import domain, create_domain from halfapi.cli.domain import domain, create_domain
from halfapi.lib.responses import ORJSONResponse from halfapi.lib.responses import ORJSONResponse
from halfapi.lib.jwt_middleware import JWTAuthenticationBackend from halfapi.lib.jwt_middleware import JWTAuthenticationBackend
logger = logging.getLogger('halfapitest')
logger = logging.getLogger()
PROJNAME = os.environ.get('PROJ','tmp_api') PROJNAME = os.environ.get('PROJ','tmp_api')

View File

@ -1,6 +1,5 @@
from halfapi.lib import acl from halfapi.lib import acl
import logging from halfapi.logging import logger
logger = logging.getLogger('uvicorn.asgi')
ACLS = { ACLS = {
'GET' : [{'acl':acl.public}] 'GET' : [{'acl':acl.public}]