adamghill / django-rich-logging

A prettier way to see Django requests while developing.
MIT License
44 stars 2 forks source link

Display log time #5

Closed sjbitcode closed 2 years ago

sjbitcode commented 2 years ago

Summary

This PR adds an extra column to the rich Console output for displaying the time.

Changes

💡 In order to display a time, the logging handler needs a formatter that specifies a datefmt. This is needed so that the formatter can call formatTime, and we use that value to display!

Testing

  1. Default formatter: Run the example project to see the default formatter at work! Time format will be HH:MM:SS
  2. Custom formatter: Add one of the pre-defined formatter to the django_rich_logging handler here. Time format will be whatever the formatter's datefmt setting is.
    • For example if you add "formatter": "verbose",, the time format will be YYYY-MM-DD HH:MM:SS

Notes, Questions, & Follow-up

sjbitcode commented 2 years ago

I think this is ready for review now! I changed my approach twice 🙃 Let me know if I need to change/add anything!