Add options and context manager support to log_timed().
Review Request #14365 — Created March 11, 2025 and submitted
log_timed()
has been updated to take in an optionallogger
argument
to specify a customer logger andextra
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.
- Change Summary:
-
Removed deprecated
utcnow()
calls. - Description:
-
log_timed()
has been updated to take in an optionallogger
argumentto specify a customer logger and extra
to populate additional logfields. It also now works as a context manager, which handles stopping a log
when an exception occurs. This should simplify usage overall. All arguments after
message
are now keyword-only. This will beenforced in Djblets 7. ~ Typing has been added, and documentation has been modernized to meet
~ current standards. Unit tests were added. ~ Deprecated calls for datetimes have been fixed. Typing has been added.
~ Documentation has been modernized to meet current standards. Unit tests + were added. - Commits:
-
Summary ID 12d6721e3f08b89c501796d55c452f662cc48113 85f0ee27d55d3a8043f66fc9a5d8b5fa19cec2b7
Checks run (2 succeeded)
- Change Summary:
-
- Added trace ID support.
- Fixed missing docstrings.
- Fixed the return type for
__exit__
.
- Description:
-
log_timed()
has been updated to take in an optionallogger
argumentto specify a customer logger and extra
to populate additional logfields. 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 beenforced 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. - Commits:
-
Summary ID 85f0ee27d55d3a8043f66fc9a5d8b5fa19cec2b7 fc24f9317fe134e998123525304833c0ed41b99c
Checks run (2 succeeded)
- Change Summary:
-
Fixed a custom
trace_id
not being passed toTimedLogInfo
. - Commits:
-
Summary ID fc24f9317fe134e998123525304833c0ed41b99c 3c4817f2b1e69ce5be3b6740d0e3283f7a817683
Checks run (2 succeeded)
- Change Summary:
-
Fixed the UTC reference to work with Python 3.8.
- Commits:
-
Summary ID 3c4817f2b1e69ce5be3b6740d0e3283f7a817683 e4266b7f8e276dd605016f0b0a0daffee2c7c0a7