Anki is a smart spaced repetition flashcard program
Find a file
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
.buildkite Update n2 for Windows console fix; recommend it on Windows as well 2023-07-02 19:03:37 +10:00
.cargo Fix i18n build script not responding to env var changes 2023-07-04 17:17:41 +10:00
.config Drop workspace-hack in favor of workspace deps 2023-06-23 17:41:31 +10:00
.github/ISSUE_TEMPLATE Move away from Bazel (#2202) 2022-11-27 15:24:20 +10:00
.vscode.dist Fix Select component not reacting to changed list (#2885) 2023-12-11 09:12:34 +10:00
build Honor NINJA_STATUS if already set (#2984) 2024-02-01 14:56:14 +10:00
cargo Keep previous FSRS parameters if they get worse when optimizing (#2996) 2024-02-11 16:26:04 +10:00
docs Add make to build reqs; update ARM docs 2023-12-30 09:45:39 +10:00
ftl update FSRS to v0.2.0 (#2977) 2024-01-30 16:27:12 +10:00
proto Keep previous FSRS parameters if they get worse when optimizing (#2996) 2024-02-11 16:26:04 +10:00
pylib Add support for python logging (#2969) 2024-02-11 16:41:50 +10:00
python Update for jinja2 security warning 2024-01-12 15:17:26 +10:00
qt Add support for python logging (#2969) 2024-02-11 16:41:50 +10:00
rslib Keep previous FSRS parameters if they get worse when optimizing (#2996) 2024-02-11 16:26:04 +10:00
sass Improve visibility of clicked buttons in editor (#2841) 2023-11-23 16:56:45 +10:00
tools fix: fix windows build issue (#2947) 2024-01-19 15:48:06 +10:00
ts Keep previous FSRS parameters if they get worse when optimizing (#2996) 2024-02-11 16:26:04 +10:00
.deny.toml Update to latest fsrs-rs 2023-12-07 14:13:58 +10:00
.dprint.json Allow disabling occlusion mask border (#2764) 2023-10-23 11:43:37 +10:00
.eslintrc.js Enforce curly bracket usage for one-statement ifs 2023-10-23 09:19:49 +10:00
.gitattributes try again to improve GitHub's language stats 2021-01-20 13:20:45 +10:00
.gitignore Merging Notetypes on Import (#2612) 2023-09-09 09:00:55 +10:00
.gitmodules Exclude PyOxidizer from recursive checkout 2023-07-02 18:22:44 +10:00
.isort.cfg Move away from Bazel (#2202) 2022-11-27 15:24:20 +10:00
.mypy.ini Move away from Bazel (#2202) 2022-11-27 15:24:20 +10:00
.pylintrc Add ability to restore a notetype to its original configuration (#2472) 2023-04-18 14:07:51 +10:00
.rustfmt-empty.toml Move away from Bazel (#2202) 2022-11-27 15:24:20 +10:00
.rustfmt.toml Move ascii_percent_encoding into a separate repo 2023-04-12 08:45:23 +10:00
.version Bump version to 23.12.1 2023-12-28 18:19:48 +10:00
Cargo.lock Keep previous FSRS parameters if they get worse when optimizing (#2996) 2024-02-11 16:26:04 +10:00
Cargo.toml Keep previous FSRS parameters if they get worse when optimizing (#2996) 2024-02-11 16:26:04 +10:00
check Add a shortcut to auto-format before running checks 2023-07-02 09:59:05 +10:00
CONTRIBUTORS Add support for python logging (#2969) 2024-02-11 16:41:50 +10:00
LICENSE Replace css_browser_selector with our own implementation (#2854) 2023-11-30 10:57:33 +10:00
ninja Switch runner to release build 2023-07-02 10:31:07 +10:00
package.json Replace css_browser_selector with our own implementation (#2854) 2023-11-30 10:57:33 +10:00
pkgkey.asc add public key for release signing 2018-09-18 10:40:45 +10:00
README.md Updated README (#2718) 2023-10-11 14:11:07 +10:00
run Fix webengine remote debugging in Qt6 2023-11-05 12:41:17 +10:00
run.bat Fix webengine remote debugging in Qt6 2023-11-05 12:41:17 +10:00
rust-toolchain.toml Update to Rust 1.75 2024-01-05 14:28:23 +10:00
SECURITY.md add SECURITY.md 2021-09-22 22:55:19 +10:00
yarn.lock Replace css_browser_selector with our own implementation (#2854) 2023-11-30 10:57:33 +10:00

Anki

Build status

This repo contains the source code for the computer version of Anki.

About

Anki is a spaced repetition program. Please see the website to learn more.

Getting Started

Anki Betas

If you'd like to try development builds of Anki but don't feel comfortable building the code, please see Anki betas

Developing

For more information on building and developing, please see Development.

Contributing

Want to contribute to Anki? Check out the Contribution Guidelines.

Anki Contributors

CONTRIBUTORS

License

Anki's license: LICENSE