Closed pletnes closed 2 years ago
Hello Paul, for the first question to get the JSON output you have to init the cf_logging before getting the logger. If you move cf_logging.init(level=log_level) to line 10 it should work.
For the integration, take a look at the sanic or flask folders within the package. In the init.py the setup is done - basically the class Framework is initialized with a context, request_reader, response_reader and middlewares are setup + before after request handlers. The idea is that the context stores information about the request/response time. The handlers, afterwards, display the timing and correlationId of the request.
Best regards
Thanks for the clarification!
Hi,
I've been trying to use cf-python-logging-support to JSON format my logs correctly. I'm using FastAPI, which is unfortunately not supported (yet?). I made a small demo app here, but I only get regular "default-formatted" logs, no JSON logs, even though the
logging_tree.printout()
claims there's a JSON formatter and handler configured.Here's my code. Any ideas? https://github.wdf.sap.corp/i506278/cf-fastapi-logging https://github.wdf.sap.corp/i506278/cf-fastapi-logging/commit/bd5d1f3c2ad732deab74be925f904a51c2f99766
Any suggestions for how to integrate FastAPI further with
cf_logging
? I guess it could be integrated as a middleware, similar to what you have for sanic, but I haven't looked into that yet.Cheers Paul