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!
Have DjangoRequestHandler.__init__ set a default formatter if none is passed in, else use passed in formatter
Have DjangoRequestHandler.emit call formatTime on its formatter and adds extra column to log output
Adds DjangoRequestHandler.__init__ tests 🧪
Testing
Default formatter: Run the example project to see the default formatter at work! Time format will be HH:MM:SS
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
Modify README to include note about optionally passing a formatter to the django_rich_logging handler
Should the tests check for the cell content?
current tests does minimal checking for the Method and text color
time checking would require something like freezegun?
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 callformatTime
, and we use that value to display!DjangoRequestHandler.__init__
set a default formatter if none is passed in, else use passed in formatterDjangoRequestHandler.emit
callformatTime
on its formatter and adds extra column to log outputDjangoRequestHandler.__init__
tests 🧪Testing
HH:MM:SS
django_rich_logging
handler here. Time format will be whatever the formatter'sdatefmt
setting is."formatter": "verbose",
, the time format will beYYYY-MM-DD HH:MM:SS
Notes, Questions, & Follow-up
django_rich_logging
handlerMethod
and text colorfreezegun
?