django / daphne

Django Channels HTTP/WebSocket server
BSD 3-Clause "New" or "Revised" License
2.32k stars 256 forks source link

Disable logging when verbosity=0 #415

Closed abhi1693 closed 2 years ago

abhi1693 commented 2 years ago

Depends on #414

abhi1693 commented 2 years ago

@carltongibson I already have disable_existing_loggers=True and yet daphne prints my JSON structured logs again to the console as JSON string along with the original log. With verbosity=0, with my changes, I was able to fix this to avoid invalid console prints.

Would it make sense to set verbosity=-1 then?

Current behaviour

{"request_id": "10a9e8a85d4e7804f8971bdb82e69d2b", "user_id": null, "ip": "x.x.x.x", "event": "Testing loggers", "timestamp": "2022-04-11T03:37:53.900919Z", "logger": "oms.base", "level": "info"}
2022-04-11 03:37:53,900 INFO     {'request_id': '10a9e8a85d4e7804f8971bdb82e69d2b', 'user_id': None, 'ip': 'x.x.x.x', 'event': 'Testing loggers', 'timestamp': '2022-04-11T03:37:53.900919Z', 'logger': 'oms.base', 'level': 'info'}

Expected behaviour:

{"request_id": "10a9e8a85d4e7804f8971bdb82e69d2b", "user_id": null, "ip": "x.x.x.x", "event": "Testing loggers", "timestamp": "2022-04-11T03:37:53.900919Z", "logger": "oms.base", "level": "info"}