Anki/qt/aqt
cav71 f4a8f7d9c7
Add support for python logging (#2969)
* adds log module

* enable logging in the app

* adds a getLogger method to AddonManager

* change log level depending on ANKIDEV

* fix undefined module variable

* - fix addons log file path
- remove a breakpoint leftover

set the addons log files under pm.addonFolder()/NNNNNN/user_files/logs/NNNNNN.log

* fix path bug

* move log closing handling into AddonManager deleteAddon/backupUserFiles methods

* logging module level import
fix undefined variable in backupUserFiles

* pretty format log records

* move MediaServer log into logging

* update CONTRIBUTORS

* documentation cleanup

* capture warnings into log messages
fix waitress verbosity

* remove record_factory function

* add get_logger method alias to getLogger in AddonManager
switch to TimedRotatingFileHandler handler
fix minor typo

* set main log level to DEBUG if ANKIDEV is not 0 (or unset)
added two new methods to AddonManager addon_get_logger/addon_toggle_log_level

* add new find_logger_output to AddonManager

* move logs under pm.base

* change log output

* update addonmanager getlogger

* Format imports

* Refactor logging set-up slightly and tweak docstring

* Remove obsolete log closing statements

As logs are no longer stored in user_files, we do not need to close their handlers

* Refactor and try to simplify log module

* Remove demo code

* Refactor and update add-on manager logging API

* Simplify writing unit tests for add-ons that use logging

Loggers are likely to be also employed in non UI code, so it seems like a good idea to decouple them from requiring a running Anki instance to work (thus freeing add-on authors from the need to mock Anki APIs in their tests).

* Fix arguments and drop obsolete inline instructions

Lets add a section on logging to the add-on docs instead

* Drop unnecessary import

* Supply logging basicConfig force option by default

Until we change the module import order and thus ensure that `log` is always evaluated before third-party dependencies have a chance to initialize the root logger, `force` is non-optional.

* Fix formatting and type errors

* Restore mediasrv type ignore comments

* Add note on prefix API stability

* Consistently use addon_from_module in new code

* Use logFolder rather than profileFolder

* Adjust method name for PEP8

* Change loggerDict access path, satisfying pylint

* Drop unused import and use lazy % formatting

* lint fix

* refactor .log_folder -> .addon_logs
store anki.log under logdir

* Fix method name (dae)

* Disable file-based logging in the backend (dae)

I have never found this useful, and it logs nothing by default, so
creating/opening the file is a waste. Removing it also ensures that
addon_logs() is solely used for add-ons.

---------

Co-authored-by: Glutanimate <5459332+glutanimate@users.noreply.github.com>
2024-02-11 16:41:50 +10:00
..
browser Initialize Browser.aspect_ratio earlier to fix AttributeError (#2924) 2024-01-03 15:59:16 +10:00
data Fix flicker when hovering over deck list (#2958) 2024-01-23 14:20:32 +10:00
forms Fix code completion in Qt forms (#2993) 2024-02-08 15:24:12 +10:00
import_export Allow im-/exporting with or without deck configs (#2804) 2023-11-13 13:54:41 +10:00
operations Drop support for checkpoints (#2742) 2023-10-17 12:43:34 +10:00
qt Automatically disable sandbox on Qt5 PyPi/packaged builds 2023-11-16 10:28:58 +10:00
__init__.py Add support for python logging (#2969) 2024-02-11 16:41:50 +10:00
_macos_helper.py Move away from Bazel (#2202) 2022-11-27 15:24:20 +10:00
about.py Fix macOS clipboard issues (#2900) 2023-12-22 14:18:19 +10:00
addcards.py Improve confirmation message in Add screen (#2903) 2023-12-24 15:22:59 +10:00
addons.py Add support for python logging (#2969) 2024-02-11 16:41:50 +10:00
changenotetype.py Update Python deps 2023-03-31 14:04:05 +10:00
clayout.py Change default font in code editors (#2985) 2024-02-02 17:03:29 +10:00
colors.py Move away from Bazel (#2202) 2022-11-27 15:24:20 +10:00
customstudy.py Move away from Bazel (#2202) 2022-11-27 15:24:20 +10:00
dbcheck.py Backup improvements (#1728) 2022-03-21 19:40:42 +10:00
debug_console.py Pass dict for locals and globals to exec() (#2590) 2023-07-25 21:21:06 +10:00
deckbrowser.py Preserve _renderStats() signature to avoid add-on breakage 2023-12-14 10:57:50 +10:00
deckchooser.py Make dialogs non-blocking (#1650) 2022-02-10 09:53:13 +10:00
deckconf.py Drop support for checkpoints (#2742) 2023-10-17 12:43:34 +10:00
deckdescription.py Update Python deps 2023-03-31 14:04:05 +10:00
deckoptions.py Remove v1/v2 support from the backend (#2727) 2023-10-14 10:50:59 +10:00
editcurrent.py Apply same ctrl+numpad enter fix that the add screen has 2023-10-26 11:57:37 +10:00
editor.py Make sure editor note is saved before triggering buttons (#2995) 2024-02-11 16:07:49 +10:00
emptycards.py Rework & unify webview identification and title setting (#2366) 2023-02-10 14:53:11 +10:00
errors.py Catch another invalid-timestamp error 2023-12-11 12:39:20 +10:00
exporting.py Change export notes' parent window in card browser (#2761) 2023-10-22 10:23:58 +10:00
fields.py Skip template checks in Fields screen (#2670) 2023-09-20 16:09:54 +10:00
filtered_deck.py Use seconds instead of minutes for preview delay 2023-12-21 11:02:29 +10:00
flags.py Introduce new color palette using Sass maps (#2016) 2022-09-16 14:11:18 +10:00
gui_hooks.py Move away from Bazel (#2202) 2022-11-27 15:24:20 +10:00
importing.py Drop support for checkpoints (#2742) 2023-10-17 12:43:34 +10:00
legacy.py Import submodules directly (#1662) 2022-02-13 13:40:47 +10:00
log.py Add support for python logging (#2969) 2024-02-11 16:41:50 +10:00
main.py More fixes for auto advance state (#2879) 2023-12-13 09:23:11 +10:00
mediacheck.py Increase default size of media check screen 2023-07-03 23:58:24 +10:00
mediasrv.py Add support for python logging (#2969) 2024-02-11 16:41:50 +10:00
mediasync.py Prevent media syncing from blocking collection tasks (#2740) 2023-10-17 09:47:50 +10:00
modelchooser.py Add callback and non-blocking option to StudyDeck (#1643) 2022-02-07 22:05:59 +10:00
models.py fix: refresh model list when legacy addon adds notetype (#2825) 2023-11-13 10:36:21 +10:00
mpv.py Fix ModuleNotFoundError: No module named 'distutils' (#2723) 2023-10-11 14:12:18 +10:00
notetypechooser.py Make dialogs non-blocking (#1650) 2022-02-10 09:53:13 +10:00
overview.py Drop support for checkpoints (#2742) 2023-10-17 12:43:34 +10:00
package.py Fix startup failure in macOS bundle 2023-10-14 13:49:33 +10:00
preferences.py Don't restrict answer key shortcuts 2023-11-13 16:09:32 +10:00
profiles.py Add support for python logging (#2969) 2024-02-11 16:41:50 +10:00
progress.py Ensure progress windows get cleaned up 2023-12-08 13:54:32 +10:00
props.py Move away from Bazel (#2202) 2022-11-27 15:24:20 +10:00
py.typed mark anki and aqt modules as having typing info 2020-01-13 13:03:37 +10:00
reviewer.py Default to 'Bury Card' action consistently (#2950) 2024-01-19 15:49:16 +10:00
schema_change_tracker.py Add ability to restore a notetype to its original configuration (#2472) 2023-04-18 14:07:51 +10:00
sound.py Fix mpv idle notification not using main thread 2023-12-06 11:40:05 +10:00
stats.py Update Python deps 2023-03-31 14:04:05 +10:00
studydeck.py Fix filter area not starting focused on Qt 6.6.1 2023-12-06 14:30:46 +10:00
stylesheets.py Workaround Ubuntu ignoring tooltip palette in dark mode 2023-05-31 15:19:10 +10:00
switch.py Auto-hide toolbar in Reviewer (#2262) 2023-01-09 14:39:31 +10:00
sync.py Fix sync status check blocking collection access 2023-12-10 12:37:01 +10:00
tagedit.py switch to new-style PyQt scoped enums and Qt6 2021-10-15 12:57:19 +10:00
taglimit.py Move custom study tag and limit gathering+saving into the backend 2022-03-10 16:23:03 +10:00
taskman.py Fix mpv idle notification not using main thread 2023-12-06 11:40:05 +10:00
theme.py Fix misalignment of IO masks in Qt5 when image is vertically long (#2829) 2023-11-16 10:30:54 +10:00
toolbar.py Reduce shaking of bottom bar (#2734) 2023-10-15 10:06:28 +10:00
tts.py Fix TTS not working properly with auto advance (#2874) 2023-12-06 11:45:33 +10:00
undo.py fix redo menu item showing undo text 2021-08-04 10:28:45 +10:00
update.py Fix update suppression 2024-01-09 14:12:26 +10:00
utils.py Use our translation of 'Discard' (#2920) 2024-01-01 14:20:31 +10:00
webview.py Fix toolbar button shifting on hover (#2928) 2024-01-03 16:53:37 +10:00
widgetgallery.py Improve debug console (#2435) 2023-03-15 15:29:05 +10:00
winpaths.py run pyupgrade over codebase [python upgrade required] 2021-10-04 15:05:48 +10:00