Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh-76913: Add "merge extras" feature to LoggerAdapter #107292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 15, 2023

Conversation

romuald
Copy link
Contributor

@romuald romuald commented Jul 26, 2023

By default, LoggerAdapter objects ignores all extra= parameter used in the individual log methods, which may be confusing for some users.

This commit is aimed at adding an option in the LoggerAdapter class to allow instances / subclasses to merge both the adapter and individual log call extra into a single entry

The default behavior is not changed

For example:

log = LoggerAdapter(..., extra={"component": "XYZ"})
log.info("return %r" % ret, extra={"duration": elapsed})

@ghost
Copy link

ghost commented Jul 26, 2023

All commit authors signed the Contributor License Agreement.
CLA signed

@romuald
Copy link
Contributor Author

romuald commented Jul 26, 2023

I'm aware that the documentation / news were not updated. Waiting for some approval on the proposal first

@romuald romuald force-pushed the loggeradapter-merge-extras branch from b7fae18 to 3ebace6 Compare July 26, 2023 12:35
Copy link
Member

@vsajip vsajip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see suggested changes, and add documentation and NEWS changes. Thanks!

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@vsajip vsajip added the type-feature A feature request or enhancement label Jul 30, 2023
@romuald romuald force-pushed the loggeradapter-merge-extras branch from 8221e75 to 92b6254 Compare July 30, 2023 13:45
@romuald
Copy link
Contributor Author

romuald commented Jul 30, 2023

I have made the requested changes; please review again

@bedevere-bot
Copy link

Thanks for making the requested changes!

@vsajip: please review the changes made to this pull request.

@bedevere-bot bedevere-bot requested a review from vsajip July 30, 2023 13:45
@romuald
Copy link
Contributor Author

romuald commented Jul 30, 2023

(I did rewrite my commit I'm not sure what's the usual way is)

@vsajip
Copy link
Member

vsajip commented Jul 30, 2023

(I did rewrite my commit I'm not sure what's the usual way is)

I don't see any sign of the changes I suggested. The normal way to do it is to make the changes and push again to your fork/branch. This will generate a new diff, but as you can see the current diff looks just like the previous diff. Check the Python Developer's Guide if you need more help on creating and iterating pull requests.

@romuald
Copy link
Contributor Author

romuald commented Jul 30, 2023

I don't see any sign of the changes I suggested. The normal way to do it is to make the changes and push again to your fork/branch. This will generate a new diff, but as you can see the current diff looks just like the previous diff. Check the Python Developer's Guide if you need more help on creating and iterating pull requests.

I've made the code changes (visible in the PR for me) but missed the part about the NEWS and doc. I'll work on this next

@vsajip
Copy link
Member

vsajip commented Jul 31, 2023

(visible in the PR for me)

Well, it's not visible to me. See this screenshot:

ss17

Note that it's showing "Changes from all commits" but only a commit count of 1, where I would have expected at least two commits (the initial commit, and one or more for your changes after my review). Also note that I made a review comment suggesting merge_extras be renamed to merge_extra, which appears not to be reflected in the screenshot.

@romuald
Copy link
Contributor Author

romuald commented Jul 31, 2023

@vsajip thanks for the clarification. I've used a push -f to squash all changes, I'm guessing this is why it's only showing as one change

I'll try to recover this if I can access the previous state

I also missed the name change by reading too fast

romuald added 3 commits July 31, 2023 16:55
By default, LoggerAdapter objects ignores all `extra=` parameter used in
the individual log methods, which may be confusing for some users.

This commit is aimed at adding an option in the LoggerAdapter class to
allow instances / subclasses to merge both the adapter and individual
log call extra into a single entry

The default behavior is not changed

For example:

```
log = LoggerAdapter(..., extra={"component": "XYZ"})
log.info("return %r" % ret, extra={"duration": elapsed})
```
@romuald romuald force-pushed the loggeradapter-merge-extras branch from 92b6254 to 65dcfcf Compare July 31, 2023 14:56
@vsajip
Copy link
Member

vsajip commented Jul 31, 2023

Don't squash on push. We generally squash on merge, and reviewers need to see the whole commit history (initial, and after every review or noticed change) when reviewing.

@romuald
Copy link
Contributor Author

romuald commented Aug 14, 2023

I have made the requested changes; please review again

@bedevere-bot
Copy link

Thanks for making the requested changes!

@vsajip: please review the changes made to this pull request.

@vsajip
Copy link
Member

vsajip commented Aug 15, 2023

A seemingly unrelated test is failing, so I'll close and reopen this PR to see if that resolves it.

@vsajip vsajip closed this Aug 15, 2023
@vsajip vsajip reopened this Aug 15, 2023
@vsajip vsajip merged commit a482e5b into python:main Aug 15, 2023
@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot ARM Raspbian 3.x has failed when building commit a482e5b.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/424/builds/4666) and take a look at the build logs.
  4. Check if the failure is related to this commit (a482e5b) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/424/builds/4666

Summary of the results of the build (if available):

== Tests result: ENV CHANGED ==

427 tests OK.

10 slowest tests:

  • test_venv: 11 min 10 sec
  • test_multiprocessing_fork: 9 min 36 sec
  • test_largefile: 8 min 16 sec
  • test_math: 4 min 46 sec
  • test_multiprocessing_forkserver: 3 min 30 sec
  • test_multiprocessing_spawn: 3 min 24 sec
  • test_concurrent_futures: 3 min 15 sec
  • test_zipfile: 3 min 6 sec
  • test_importlib: 3 min 5 sec
  • test_tarfile: 2 min 35 sec

1 test altered the execution environment:
test_concurrent_futures

19 tests skipped:
test.test_asyncio.test_windows_events
test.test_asyncio.test_windows_utils test_devpoll test_idle
test_ioctl test_kqueue test_launcher test_perf_profiler
test_startfile test_tcl test_tkinter test_ttk test_ttk_textonly
test_turtle test_winconsoleio test_winreg test_winsound test_wmi
test_zipfile64

Total duration: 39 min 45 sec

Click to see traceback logs
remote: Enumerating objects: 28, done.        
remote: Counting objects:   3% (1/28)        
remote: Counting objects:   7% (2/28)        
remote: Counting objects:  10% (3/28)        
remote: Counting objects:  14% (4/28)        
remote: Counting objects:  17% (5/28)        
remote: Counting objects:  21% (6/28)        
remote: Counting objects:  25% (7/28)        
remote: Counting objects:  28% (8/28)        
remote: Counting objects:  32% (9/28)        
remote: Counting objects:  35% (10/28)        
remote: Counting objects:  39% (11/28)        
remote: Counting objects:  42% (12/28)        
remote: Counting objects:  46% (13/28)        
remote: Counting objects:  50% (14/28)        
remote: Counting objects:  53% (15/28)        
remote: Counting objects:  57% (16/28)        
remote: Counting objects:  60% (17/28)        
remote: Counting objects:  64% (18/28)        
remote: Counting objects:  67% (19/28)        
remote: Counting objects:  71% (20/28)        
remote: Counting objects:  75% (21/28)        
remote: Counting objects:  78% (22/28)        
remote: Counting objects:  82% (23/28)        
remote: Counting objects:  85% (24/28)        
remote: Counting objects:  89% (25/28)        
remote: Counting objects:  92% (26/28)        
remote: Counting objects:  96% (27/28)        
remote: Counting objects: 100% (28/28)        
remote: Counting objects: 100% (28/28), done.        
remote: Compressing objects:   7% (1/13)        
remote: Compressing objects:  15% (2/13)        
remote: Compressing objects:  23% (3/13)        
remote: Compressing objects:  30% (4/13)        
remote: Compressing objects:  38% (5/13)        
remote: Compressing objects:  46% (6/13)        
remote: Compressing objects:  53% (7/13)        
remote: Compressing objects:  61% (8/13)        
remote: Compressing objects:  69% (9/13)        
remote: Compressing objects:  76% (10/13)        
remote: Compressing objects:  84% (11/13)        
remote: Compressing objects:  92% (12/13)        
remote: Compressing objects: 100% (13/13)        
remote: Compressing objects: 100% (13/13), done.        
remote: Total 15 (delta 12), reused 4 (delta 2), pack-reused 0        
From https://github.com/python/cpython
 * branch                  main       -> FETCH_HEAD
Note: switching to 'a482e5bf0022f85424a6308529a9ad51f1bfbb71'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at a482e5bf00 gh-76913: Add "merge extras" feature to LoggerAdapter (GH-107292)
Switched to and reset branch 'main'

./Modules/_testcapi/heaptype_relative.c: In function ‘make_sized_heaptypes’:
./Modules/_testcapi/heaptype_relative.c:62:28: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
   62 |                            (unsigned long long)data_ptr,
      |                            ^

make: *** [Makefile:2023: buildbottest] Error 3

iritkatriel pushed a commit to iritkatriel/cpython that referenced this pull request Aug 16, 2023
@romuald romuald deleted the loggeradapter-merge-extras branch August 17, 2023 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-feature A feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants