NAFF
NAFF copied to clipboard
fix💥: Make naff always use the correct logger (v2)
What type of pull request is this?
- [ ] Non-breaking code change
- [x] Breaking code change
- [ ] Documentation change/addition
- [ ] Tests change
Description
Naff was not always using the correct logger. This was due to the logger being imported before the imported variable was changed on Client initialisation.
const.logger has been converted to a function which ensures the fetched object is the set one.
Technically breaking if anyone imported and used the logger
Changes
- convert
const.loggerto a function
Checklist
- [x] I've formatted my code with Black
- [x] I've ensured my code works on
Python 3.10.x - [x] I've tested my code
This does not appear to work:
All existing projects i open encounter this error:
Traceback (most recent call last):
File "C:\Users\LordOfPolls\AppData\Local\JetBrains\Toolbox\apps\PyCharm-P\ch-0\222.3739.56\plugins\python\helpers\pydev\pydevd.py", line 1496, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Users\LordOfPolls\AppData\Local\JetBrains\Toolbox\apps\PyCharm-P\ch-0\222.3739.56\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:/Users/LordOfPolls/Documents/Projects/NAFF/_main_test.py", line 12, in <module>
bot = naff.Client(
File "C:\Users\LordOfPolls\Documents\Projects\NAFF\naff\client\client.py", line 409, in __init__
self._sanity_check()
File "C:\Users\LordOfPolls\Documents\Projects\NAFF\naff\client\client.py", line 503, in _sanity_check
self.logger.debug("Running client sanity checks...")
AttributeError: 'function' object has no attribute 'debug'
This does not appear to work:
All existing projects i open encounter this error:
Traceback (most recent call last): File "C:\Users\LordOfPolls\AppData\Local\JetBrains\Toolbox\apps\PyCharm-P\ch-0\222.3739.56\plugins\python\helpers\pydev\pydevd.py", line 1496, in _exec pydev_imports.execfile(file, globals, locals) # execute the script File "C:\Users\LordOfPolls\AppData\Local\JetBrains\Toolbox\apps\PyCharm-P\ch-0\222.3739.56\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "C:/Users/LordOfPolls/Documents/Projects/NAFF/_main_test.py", line 12, in <module> bot = naff.Client( File "C:\Users\LordOfPolls\Documents\Projects\NAFF\naff\client\client.py", line 409, in __init__ self._sanity_check() File "C:\Users\LordOfPolls\Documents\Projects\NAFF\naff\client\client.py", line 503, in _sanity_check self.logger.debug("Running client sanity checks...") AttributeError: 'function' object has no attribute 'debug'
Apparently I only tested this with a logger supplied. There was one parenthesis missing