This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sentry_sdk | |
from fastapi import FastAPI | |
sentry_sdk.init( | |
dsn="your_dns", | |
) | |
app = FastAPI() | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
from fastapi import FastAPI | |
from uicheckapp.services import EchoService | |
logging.config.fileConfig('logging.conf', disable_existing_loggers=False) | |
logger = logging.getLogger(__name__) | |
app = FastAPI() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.middleware("http") | |
async def log_requests(request: Request, call_next): | |
idem = ''.join(random.choices(string.ascii_uppercase + string.digits, k=6)) | |
logger.info(f"rid={idem} start request path={request.url.path}") | |
start_time = time.time() | |
response = await call_next(request) | |
process_time = (time.time() - start_time) * 1000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
logger = logging.getLogger(__name__) # the __name__ resolve to "uicheckapp.services" | |
# This will load the uicheckapp logger | |
class EchoService: | |
def echo(self, msg): | |
logger.info("echoing something from the uicheckapp logger") | |
print(msg) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
from fastapi import FastAPI | |
from uicheckapp.services import EchoService | |
# setup loggers | |
logging.config.fileConfig('logging.conf', disable_existing_loggers=False) | |
# get root logger | |
logger = logging.getLogger(__name__) # the __name__ resolve to "main" since we are at the root of the project. | |
# This will get the root logger since no logger in the configuration has this name. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[loggers] | |
keys=root,uicheckapp | |
[handlers] | |
keys=consoleHandler,detailedConsoleHandler | |
[formatters] | |
keys=normalFormatter,detailedFormatter | |
[logger_root] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import graphene | |
from fastapi import FastAPI | |
from starlette.graphql import GraphQLApp | |
from graphql.execution.executors.asyncio import AsyncioExecutor | |
class Query(graphene.ObjectType): | |
hello = graphene.String( | |
name=graphene.String(default_value="stranger") | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am philippegirard on github. | |
* I am philippegirard (https://keybase.io/philippegirard) on keybase. | |
* I have a public key ASDRpmjw9gY3zLi2-i8rQG_rcL4zHQwUZ6i6cq0kkD2pUAo | |
To claim this, I am signing this object: |
NewerOlder