Skip to content

fix: Respect BASIC_MEMORY_LOG_LEVEL and BASIC_MEMORY_CONSOLE_LOGGING environment variables#264

Merged
jope-bm merged 1 commit into
mainfrom
fix-255-logging-config
Aug 22, 2025
Merged

fix: Respect BASIC_MEMORY_LOG_LEVEL and BASIC_MEMORY_CONSOLE_LOGGING environment variables#264
jope-bm merged 1 commit into
mainfrom
fix-255-logging-config

Conversation

@jope-bm
Copy link
Copy Markdown
Contributor

@jope-bm jope-bm commented Aug 21, 2025

Summary

Fixes #255 - Console logging was ignoring BASIC_MEMORY_CONSOLE_LOGGING=false and log_level=ERROR settings.

Root Cause

The logging setup function was not properly reading environment variables before falling back to config file settings. This was due to a timing issue where logging setup occurred during module import before environment variables could be processed through Pydantic's settings system.

Changes Made

Environment Variable Support:

  • BASIC_MEMORY_LOG_LEVEL environment variable is now properly read and used
  • BASIC_MEMORY_CONSOLE_LOGGING now accepts multiple truthy values: "true", "1", "yes", "on" (case-insensitive)
  • ✅ Environment variables take precedence over config file settings as expected

Technical Implementation:

  • Modified setup_basic_memory_logging() in src/basic_memory/config.py
  • Added direct environment variable reading before config fallback
  • Enhanced boolean parsing for console logging setting

Testing

Verified that the following configurations now work correctly:

# Disable console logging entirely
BASIC_MEMORY_CONSOLE_LOGGING=false BASIC_MEMORY_LOG_LEVEL=ERROR basic-memory command

# Enable console logging with ERROR level only
BASIC_MEMORY_CONSOLE_LOGGING=true BASIC_MEMORY_LOG_LEVEL=ERROR basic-memory command

# Alternative truthy values
BASIC_MEMORY_CONSOLE_LOGGING=1 basic-memory command
BASIC_MEMORY_CONSOLE_LOGGING=yes basic-memory command

Before vs After

Before:

  • BASIC_MEMORY_LOG_LEVEL ignored completely
  • ❌ Console shows INFO/DEBUG logs regardless of settings
  • ❌ Only accepts exactly "true" for console logging

After:

  • BASIC_MEMORY_LOG_LEVEL=ERROR correctly filters to ERROR+ only
  • BASIC_MEMORY_CONSOLE_LOGGING=false properly disables console output
  • ✅ Accepts "true", "1", "yes", "on" for console logging

Test plan

  • Environment variables properly override config file settings
  • Log level filtering works correctly (ERROR only shows ERROR/CRITICAL)
  • Console logging can be disabled via environment variable
  • Multiple truthy values accepted for console logging
  • Existing functionality preserved (config-based tests still pass)
  • No regressions in related functionality

🤖 Generated with Claude Code

…environment variables

Resolves #255 where console logging configuration was not properly respecting environment variables.

Changes:
- BASIC_MEMORY_LOG_LEVEL environment variable is now read and used before falling back to config file
- BASIC_MEMORY_CONSOLE_LOGGING now accepts multiple truthy values: "true", "1", "yes", "on" (case-insensitive)
- Fixed timing issue where logging setup occurred before environment variables could be processed

The logging setup function now directly reads environment variables first, ensuring user settings are respected immediately during application startup.

Signed-off-by: Claude <noreply@anthropic.com>

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Joe P <joe@basicmemory.com>
@jope-bm jope-bm force-pushed the fix-255-logging-config branch from d7f0021 to 3967bd7 Compare August 21, 2025 19:58
@jope-bm jope-bm requested a review from phernandez August 21, 2025 20:08
Copy link
Copy Markdown
Member

@phernandez phernandez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I always hate logging.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Aug 21, 2025

CLA assistant check
All committers have signed the CLA.

@jope-bm jope-bm merged commit 9743fcd into main Aug 22, 2025
9 checks passed
@jope-bm jope-bm deleted the fix-255-logging-config branch August 22, 2025 13:58
groksrc pushed a commit that referenced this pull request Aug 25, 2025
…environment variables (#264)

Signed-off-by: Joe P <joe@basicmemory.com>
Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Drew Cain <groksrc@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Console logging ignores BASIC_MEMORY_CONSOLE_LOGGING=false and log_level=ERROR settings

3 participants