diff --git a/graph/fixes/missing-logger-import-causes-nameerror-in-python-modules-7b6d18.md b/graph/fixes/missing-logger-import-causes-nameerror-in-python-modules-7b6d18.md new file mode 100644 index 00000000000..377046c6207 --- /dev/null +++ b/graph/fixes/missing-logger-import-causes-nameerror-in-python-modules-7b6d18.md @@ -0,0 +1,23 @@ +--- +id: 7b6d183b-e221-471a-8078-e8639ebdd55a +type: fix +title: "Missing logger import causes NameError in Python modules" +tags: [python, logging, bug, nameerror, fix, troubleshooting] +importance: 0.5 +confidence: 0.8 +created: "2026-02-13T20:35:13.483029+00:00" +updated: "2026-02-13T20:35:13.483029+00:00" +--- + +Common bug when adding logging to existing Python code: calling logger.info() without importing logging module. + +Error: NameError: name 'logger' is not defined + +Fix: +import logging + +logger = logging.getLogger(__name__) + +Always add both lines at top of module when adding logging. + +In discord bot config.py, save() and add_project() methods called logger.info() but module lacked import. Added imports, committed, restarted service.