Add options and context manager support to log_timed().

Review Request #14365 — Created March 11, 2025 and submitted — Latest diff uploaded

Information

Djblets
release-5.x

Reviewers

log_timed() has been updated to take in an optional logger argument
to specify a customer logger and extra to populate additional log
fields.

It also now works as a context manager, which handles stopping a log
when an exception occurs. This should simplify usage overall.

Every log_timed() call has a trace ID that can be used to associate
the beginning/end/result logs together. This is exposed on the timer
object so that other log calls can include it in their logs.

All arguments after message are now keyword-only. This will be
enforced in Djblets 7.

Deprecated calls for datetimes have been fixed. Typing has been added.
Documentation has been modernized to meet current standards. Unit tests
were added.

Unit tests pass.

Changes between revision 3 and 4

orig
1
2
3
4
5
6

Commits

Summary ID Author
Add options and context manager support to log_timed().
`log_timed()` has been updated to take in an optional `logger` argument to specify a customer logger and `extra` to populate additional log fields. It also now works as a context manager, which handles stopping a log when an exception occurs. This should simplify usage overall. Every `log_timed()` call has a trace ID that can be used to associate the beginning/end/result logs together. This is exposed on the timer object so that other log calls can include it in their logs. All arguments after `message` are now keyword-only. This will be enforced in Djblets 7. Deprecated calls for datetimes have been fixed. Typing has been added. Documentation has been modernized to meet current standards. Unit tests were added.
fc24f9317fe134e998123525304833c0ed41b99c Christian Hammond
Add options and context manager support to log_timed().
`log_timed()` has been updated to take in an optional `logger` argument to specify a customer logger and `extra` to populate additional log fields. It also now works as a context manager, which handles stopping a log when an exception occurs. This should simplify usage overall. Every `log_timed()` call has a trace ID that can be used to associate the beginning/end/result logs together. This is exposed on the timer object so that other log calls can include it in their logs. All arguments after `message` are now keyword-only. This will be enforced in Djblets 7. Deprecated calls for datetimes have been fixed. Typing has been added. Documentation has been modernized to meet current standards. Unit tests were added.
3c4817f2b1e69ce5be3b6740d0e3283f7a817683 Christian Hammond
djblets/log/__init__.py
Loading...