json-logging-python icon indicating copy to clipboard operation
json-logging-python copied to clipboard

pull changes from SAP/cf-python-logging-support add support for Django and Falcon

Open bobbui opened this issue 4 years ago • 8 comments

https://github.com/SAP/cf-python-logging-support have a quite similar setup in term of adding framework support. We can pull Django and Falcon support from https://github.com/SAP/cf-python-logging-support/tree/master/sap/cf_logging/django_logging and https://github.com/SAP/cf-python-logging-support/tree/master/sap/cf_logging/falcon_logging to json_logging

bobbui avatar Jul 20 '19 08:07 bobbui

Is it better to do this in this module, or another that uses json_logging.register_framework_support.

Whether in this package or another, the way to make it easy for a Django developer is to use a Django middleware and the LOGGING_CONFIG setting which can pre-process the dictionary usually passed to logging.dictConfig.

This would look like this in a Django settings file:

MIDDLEWARE = [
    'logging_config.framework.django.RequestResponseMiddleware',
    # ... rest of middleware
]

LOGGING_CONFIG='json_logging.framework.django.config_logging'

And then the LOGGING_CONFIG callable would do the required wiring:

def configure_logging(logging_dict):
    logging.dictConfig(logging_dict)
    json_logging.ENABLE_JSON_LOGGING = True
    json_logging.init_django()

danizen avatar Oct 11 '19 17:10 danizen

@danizen yeah, we can leverage the register_framework_support to add django support. PR is welcomed!

bobbui avatar Oct 12 '19 05:10 bobbui

@thangbn, I have a broken wrist right now. I code slow until healed. But wait a month or so.

I've also been wondering about the correlation id, and auto headers added in the cloud. If you are running behind an AWS ALB, it will send X-Amzn-Trace-Id. But this has an internal structure. I'm not sure whether this module makes a requirement on the structure of the Correlation ID header (e.g. UUID or something).

danizen avatar Oct 21 '19 19:10 danizen

@danizen Sorry to hear that, hope you have a speedy recovery. sure that is something i can look into, i also plan to support custom list of headers to be logged together with correlation-id (e.g trace id, span id used by opentracing)

bobbui avatar Oct 21 '19 22:10 bobbui

@thangbn , @danizen are there any plans on completing this any time soon, or should I rather try tackling this myself from scratch?

kshpytsya avatar Jul 27 '20 17:07 kshpytsya

@kshpytsya i really dont have time to to this, you are very welcome to create a PR, it should relatively straight forward to do. Thanks in advance.

bobbui avatar Jul 27 '20 19:07 bobbui

Hi, is this still being worked on? I'd love to contribute as I really need Django support but I'm kind of a python beginner, so I don't even have a clue where to start...

obvionaoe avatar Nov 12 '21 11:11 obvionaoe

Hi, is this still being worked on? I'd love to contribute as I really need Django support but I'm kind of a python beginner, so I don't even have a clue where to start...

Feel free to submit it, we can all improve it together. no worries

bobbui avatar Nov 12 '21 20:11 bobbui