claude-memory/graph/fixes/missing-logger-import-causes-nameerror-in-python-modules-7b6d18.md
2026-02-13 14:35:29 -06:00

29 lines
863 B
Markdown

---
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:29.511702+00:00"
relations:
- target: d0e2e9ab-9a46-44b3-b749-8c2a562d0a1b
type: RELATED_TO
direction: outgoing
strength: 0.8
---
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.