Skip to main content

Module logging

Module logging 

Source
Expand description

Logging infrastructure for sqlmodel-console.

This module provides lightweight logging support for debugging console operations without requiring external dependencies. Logging can be enabled via environment variables.

§Environment Variables

  • SQLMODEL_LOG=1 - Enable logging output
  • SQLMODEL_LOG_LEVEL=debug|info|warn|error - Set minimum log level

§Usage

use sqlmodel_console::logging::{log_debug, log_info};

log_info!("Initializing console");
log_debug!("Mode detected: {}", mode);

In tests, use with_logging_enabled to capture logs:

use sqlmodel_console::logging::with_logging_enabled;

with_logging_enabled(|| {
    // Your code here - logs will be printed to stderr
});

Macros§

log_debug
Log a debug message.
log_error
Log an error message.
log_info
Log an info message.
log_trace
Log a trace message.
log_warn
Log a warning message.

Enums§

LogLevel
Log levels for console operations.

Functions§

disable_logging
Disable logging programmatically.
enable_logging
Enable logging programmatically (useful for tests).
init_logging
Initialize logging from environment variables.
is_logging_enabled
Check if logging is enabled.
min_log_level
Get the current minimum log level.
set_log_level
Set the minimum log level programmatically.
with_logging_enabled
Run a closure with logging enabled, then restore previous state.