Repository navigation
Rename logger to logger_ in slack_bolt.kwargs_injection.args.Args #1032
Description
Activity
- addedenhancementNew feature or requestNew feature or request
on Feb 22, 2024 Hi @ChrisHills463 - Thank you for writing in with this suggestion! Your point about improving usability seems reasonable to me, but I'll defer to @WilliamBergamin or @seratch on tradeoffs regarding making a change like this.
We have resolved the same issue with next function this way: #394
Adding an alias in the similar way should be a reasonable solution for this need. No breaking change at all.
Reacted by William Bergamin and Sarah JiangWe have resolved the same issue with next function this way: #394
Adding an alias in the similar way should be a reasonable solution for this need. No breaking change at all.
Thanks for the feedback! I think that there is a slight difference in that unlike
next,loggeris not a Python built-in but rather a common convention, which is why I think it should be renamed tologger_since when an author refers tologgerthey are likely thinking that they are referring to their local module variable rather than that of the (decorated) function.Yeah, there is a difference, but we never bring breaking changes to this SDK (considering the number of existing apps for enterprise companies). Thus, the only option we can think of is to add an alias to support your use case.
Yeah, there is a difference, but we never bring breaking changes to this SDK (considering the number of existing apps for enterprise companies). Thus, the only option we can think of is to add an alias to support your use case.
Understood, but adding an alias would be pointless because the original
loggeris already overwritten at this point, so I think at this point there is no alternative to the author using a name other thanlogger, or providing their own alias to it.Just to clarify, bolt-python's keyword argument injection mechanism adds arguments only when you give the name in the argument list (see https://github.com/slackapi/bolt-python/blob/main/slack_bolt/kwargs_injection/utils.py to learn how it works).
Therefore, when you have
loggeroutside the listener function and you give onlylogger_in the listener method's argument list, you can use both the globalloggerand bolt's logger aslogger_within the listener function. If this does not work for your use case, we may not add such change because we've never received this feedback from other developers.Just to clarify, bolt-python's keyword argument injection mechanism adds arguments only when you give the name in the argument list (see https://github.com/slackapi/bolt-python/blob/main/slack_bolt/kwargs_injection/utils.py to learn how it works).
Therefore, when you have
loggeroutside the listener function and you give onlylogger_in the listener method's argument list, you can use both the globalloggerand bolt's logger aslogger_within the listener function. If this does not work for your use case, we may not add such change because we've never received this feedback from other developers.Thank you for the clarification! This has cleared up my misunderstanding.
It is common practice to define a variable called
loggerin a script. However, theslack_bolt.kwargs_injection.args.Argsfunction used as a decorator also defineslogger, so if you want to call your normal logger in your script you have to give it a different name. It can also be unexpected behaviour, as the author may think they are calling theloggerfrom their module, but actually they are calling a different logger instance altogether.I understand this would be a breaking change, but I think it would improve usability.
Category (place an
xin each of the[ ])Requirements
Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.