• 
      

    Add options and context manager support to log_timed().

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

    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.

    Summary ID
    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.
    ad713186449e2a9666da73b3a398adbe8c5be28d
    Description From Last Updated

    Missing docstrings.

    maubinmaubin

    trace_id needs to be passed here.

    maubinmaubin

    undefined name 'UTC' Column: 30 Error code: F821

    reviewbotreviewbot
    chipx86
    david
    1. Ship It!
    2. 
        
    maubin
    1. 
        
    2. djblets/log/__init__.py (Diff revision 2)
       
       
       
       
       
       
      Show all issues

      Missing docstrings.

    3. 
        
    chipx86
    maubin
    1. 
        
    2. djblets/log/__init__.py (Diff revisions 2 - 3)
       
       
       
       
       
       
       
       
       
      Show all issues

      trace_id needs to be passed here.

      1. Oops, that's in my tree but not in the commit. Thanks!

    3. 
        
    chipx86
    chipx86
    Review request changed
    Change Summary:

    Fixed the UTC reference to work with Python 3.8.

    Commits:
    Summary ID
    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
    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.
    e4266b7f8e276dd605016f0b0a0daffee2c7c0a7

    Checks run (1 failed, 1 succeeded)

    flake8 failed.
    JSHint passed.

    flake8

    chipx86
    david
    1. Ship It!
    2. 
        
    maubin
    1. Ship It!
    2. 
        
    chipx86
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-5.x (e615f08)