# What Log Levels Are Available in codebase-memory-mcp: The Complete Developer Guide

> Explore the DEBUG, INFO, WARN, ERROR, and NONE log levels in codebase-memory-mcp. Learn how to control output with cbm_log_set_level() or the CBM_LOG_LEVEL environment variable.

- Repository: [Martin Vogel/codebase-memory-mcp](https://github.com/DeusData/codebase-memory-mcp)
- Tags: developer-guide
- Published: 2026-07-12

---

**The codebase-memory-mcp logging subsystem provides five ordered log levels—DEBUG, INFO, WARN, ERROR, and NONE—defined in the `CBMLogLevel` enum in [`src/foundation/log.h`](https://github.com/DeusData/codebase-memory-mcp/blob/main/src/foundation/log.h), which filter output at runtime via `cbm_log_set_level()` or the `CBM_LOG_LEVEL` environment variable.**

The **codebase-memory-mcp** repository implements a lightweight, hierarchical logging system designed for C applications. Understanding what log levels are available in codebase-memory-mcp is essential for configuring appropriate verbosity in production and debugging environments. The system defines five distinct severity levels in [`src/foundation/log.h`](https://github.com/DeusData/codebase-memory-mcp/blob/main/src/foundation/log.h), ranging from verbose debugging output to complete logging suppression.

## The Five Log Levels Defined in codebase-memory-mcp

The logging granularity is controlled by the `CBMLogLevel` enum declared in [[`src/foundation/log.h`](https://github.com/DeusData/codebase-memory-mcp/blob/main/src/foundation/log.h)](https://github.com/DeusData/codebase-memory-mcp/blob/main/src/foundation/log.h#L20-L26). Each level maps to a numeric value that determines filtering behavior:

- **CBM_LOG_DEBUG** (0): Verbose debugging information representing the most granular output.
- **CBM_LOG_INFO** (1): General informational messages and standard operational logs.
- **CBM_LOG_WARN** (2): Warnings indicating non-critical problems or recoverable issues.
- **CBM_LOG_ERROR** (3): Errors indicating failure conditions requiring attention.
- **CBM_LOG_NONE** (4): Special level that disables logging entirely.

The numeric ordering ensures that setting a higher threshold filters out lower-severity messages. For example, configuring the level to `CBM_LOG_WARN` suppresses both DEBUG and INFO output.

## Programmatic Log Level Control

The runtime API allows dynamic adjustment of the global log threshold. The function `cbm_log_set_level()` defined in [`src/foundation/log.h`](https://github.com/DeusData/codebase-memory-mcp/blob/main/src/foundation/log.h) accepts any `CBMLogLevel` enum value to immediately filter subsequent log calls.

```c
#include "foundation/log.h"

/* Set minimum level to WARN - only WARN and ERROR messages appear */
cbm_log_set_level(CBM_LOG_WARN);

/* These calls are suppressed due to the current threshold */
cbm_log_debug("init.complete");
cbm_log_info("service.start");

/* These calls emit output to the configured sink */
cbm_log_warn("config.missing", "key", "database_url");
cbm_log_error("connection.failed", "reason", "timeout");

```

The implementation in [`src/foundation/log.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/src/foundation/log.c) compares the current global level against the message level before formatting or outputting any text, ensuring zero-cost filtering for suppressed messages.

## Environment Variable Configuration

For deployments where recompilation is impractical, **codebase-memory-mcp** supports the `CBM_LOG_LEVEL` environment variable. The helper function `cbm_log_init_from_env()` parses both textual identifiers ("debug", "info", "warn", "error", "none") and numeric values (0-4) at startup.

```bash

# Enable all debug output

export CBM_LOG_LEVEL=debug

# Or using numeric form

export CBM_LOG_LEVEL=0

# Run application with verbose logging

./my_application

```

The parsing logic resides in [`src/foundation/log.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/src/foundation/log.c) (lines 14-27) and is validated by the unit tests in [`tests/test_log.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/tests/test_log.c), which verify proper handling of case-insensitive strings and boundary values.

## Implementation Architecture

The logging architecture separates interface from implementation. The header [`src/foundation/log.h`](https://github.com/DeusData/codebase-memory-mcp/blob/main/src/foundation/log.h) declares the `CBMLogLevel` enum and public API functions including `cbm_log_set_level()` and `cbm_log_get_level()`. The corresponding [`src/foundation/log.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/src/foundation/log.c) file contains the level comparison logic that determines whether a message qualifies for output based on the current threshold.

When a logging function such as `cbm_log_warn()` or `cbm_log_error()` is invoked, the implementation checks if the message's level is greater than or equal to the configured global level. This filtering occurs before string formatting to minimize overhead when messages are suppressed.

## Summary

- **codebase-memory-mcp** provides five log levels: **DEBUG** (0), **INFO** (1), **WARN** (2), **ERROR** (3), and **NONE** (4).
- Control the global threshold programmatically using `cbm_log_set_level()` or via the `CBM_LOG_LEVEL` environment variable.
- The `CBMLogLevel` enum is defined in [`src/foundation/log.h`](https://github.com/DeusData/codebase-memory-mcp/blob/main/src/foundation/log.h) with implementation logic in [`src/foundation/log.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/src/foundation/log.c).
- Level filtering occurs before message formatting to ensure efficient suppression of verbose output.
- Unit tests in [`tests/test_log.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/tests/test_log.c) verify environment variable parsing and threshold behavior.

## Frequently Asked Questions

### What are the default log levels in codebase-memory-mcp?

By default, the codebase-memory-mcp logging system initializes to **CBM_LOG_INFO** (level 1), meaning DEBUG messages are suppressed while INFO, WARN, and ERROR messages are emitted. You can verify the current level by calling `cbm_log_get_level()` after initialization.

### How do I disable logging completely in codebase-memory-mcp?

Set the log level to **CBM_LOG_NONE** (value 4) either programmatically with `cbm_log_set_level(CBM_LOG_NONE)` or via the environment variable using `export CBM_LOG_LEVEL=none` or `export CBM_LOG_LEVEL=4`. This disables all logging output including errors.

### Can I use numeric values instead of names for CBM_LOG_LEVEL?

Yes, the `cbm_log_init_from_env()` function accepts both textual names (case-insensitive) and numeric strings. Valid numeric values are 0 (DEBUG), 1 (INFO), 2 (WARN), 3 (ERROR), and 4 (NONE). The parser handles string values like "0" and "4" identically to "debug" and "none".

### Where is the log level validation implemented in codebase-memory-mcp?

The validation and parsing logic is implemented in [`src/foundation/log.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/src/foundation/log.c) (lines 14-27), which converts environment variable strings to `CBMLogLevel` enum values. The enum definition itself is located in [`src/foundation/log.h`](https://github.com/DeusData/codebase-memory-mcp/blob/main/src/foundation/log.h) (lines 20-26), and comprehensive testing exists in [`tests/test_log.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/tests/test_log.c) to ensure correct level handling across edge cases.