Skip to content

Replace print() statements with structured logging in production code #2300

@Vasilije1990

Description

@Vasilije1990

Problem / Background

Several production code files use bare print() statements instead of the project's structured logging (structlog / logging). This makes it harder to control log levels, filter output, and integrate with observability tools in production deployments.

Goal

Replace all print() calls in non-test production code with appropriate logger calls using the existing logging infrastructure.

Proposed Solution

Add a module-level logger and replace print() with the appropriate log level:

import structlog
logger = structlog.get_logger(__name__)

# Instead of: print("Migration completed successfully.")
# Use:        logger.info("Migration completed successfully.")

Affected files:

  1. cognee/run_migrations.py:45,48 — Migration status messages
  2. cognee/modules/users/get_user_manager.py:62,67,72 — User registration/verification events (3 instances)
  3. cognee/tasks/temporal_awareness/build_graph_with_temporal_awareness.py:27,37 — Graph initialization and data processing status

Acceptance Criteria

  • All print() calls in the listed files are replaced with logger calls
  • Appropriate log levels are used (info for success, warning/error for failures, debug for verbose output)
  • Logger is initialized at module level following existing patterns in the codebase
  • Sensitive data (tokens, user IDs) is not logged at INFO level — use DEBUG
  • ruff check . passes
  • No test files are modified (print in tests is acceptable)

Dependencies / Blockers

None. Note: issue #2039 covers a similar concern for the metrics module specifically — this issue covers the remaining files.

Relevant Links / Resources

  • Existing logging setup: cognee/shared/logging_utils.py
  • The project uses structlog — check existing patterns in other modules for consistency

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions