Core API Reference

This section documents LogEverything’s core classes and functions as they exist in the source code, auto-generated from docstrings.

logeverything (top-level package)

LogEverything - A comprehensive logging library for Python applications.

This library allows you to add detailed logging to your Python code with minimal changes to your existing codebase. It provides function entry/exit logging, I/O call logging, print statement capturing, and more, all in a beautifully formatted and easy-to-follow way.

It also supports async-compatible logging for asyncio applications.

class logeverything.Logger(name=None, auto_setup=True, _register=True, **config)[source]

Bases: BaseLogger

A comprehensive logger interface for LogEverything.

This class provides a simple, powerful interface for logging that integrates all of LogEverything’s features while remaining easy to use.

Inherits from BaseLogger to provide a consistent API and enable extensibility.

__init__(name=None, auto_setup=True, _register=True, **config)[source]

Initialize the Logger with optional configuration.

Parameters:
  • name (Optional[str]) – Logger name (default: automatic based on caller)

  • auto_setup (bool) – Whether to automatically setup logging

  • _register (bool) – Whether to register this logger (internal parameter for bound loggers)

  • **config (Any) – Configuration options (level, visual_mode, handlers, etc.)

add(sink, **kwargs)[source]

Add a logging sink/handler (Loguru-style).

Parameters:
  • sink (Any) – File path, file object, or handler

  • **kwargs (Any) – Additional configuration options

Return type:

None

Example

logger.add(“file.log”, rotation=”500 MB”, retention=”10 days”) logger.add(sys.stderr, format=”{time} | {level} | {message}”)

add_file_logging(file_path, level=None)[source]

Add file logging to the logger.

Parameters:
  • file_path (str) – Path to the log file

  • level (Union[int, str, None]) – Logging level for the file (if different from main level)

Returns:

Self for method chaining

Return type:

Logger

add_handler(handler)[source]

Add a logging handler.

Parameters:

handler (Handler) – The logging handler to add

Return type:

None

configure(handlers=None, **kwargs)[source]

Configure the logger with LogEverything’s full configuration system.

Parameters:
  • handlers (Any) – List of handler configurations or names

  • **kwargs (Any) – Configuration options including: - level: Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL) - visual_mode: Enable visual formatting with symbols and indentation - use_symbols: Use Unicode symbols for log levels - use_indent: use visual indentation - use_colors: Enable colored log level indicators (default: True) - color_messages: Enable colored message text (default: False) - beautify: Enable beautiful formatting - file_path: File path for file logging - async_mode: Enable asynchronous logging - format: Custom log format string - And many more options from LogEverything’s configuration system

Returns:

Self for method chaining

Return type:

Logger

Examples:

# Simple configuration
log.configure(level="DEBUG", visual_mode=True)

# With message coloring control
log.configure(level="INFO", visual_mode=True, color_messages=True)

# Advanced configuration
log.configure(
    level="INFO",
    visual_mode=True,
    use_symbols=True,
    handlers=["console", "file"],
    file_path="app.log",
    async_mode=True
)

# Handler-specific configuration
log.configure(handlers=[
    {"name": "console", "level": "INFO"},
    {"name": "file", "level": "DEBUG", "file_path": "debug.log"}
])
context(context_name)[source]

Create a hierarchical logging context.

This creates a visual hierarchy in the logs, similar to how LogEverything’s decorators work but as a context manager.

Parameters:

context_name (str) – Name of the context to display in logs

Return type:

Iterator[None]

Example

with log.context(“Database Operation”):

log.info(“Connecting to database”) log.debug(“Executing query”) log.info(“Query completed”)

critical(message, *args, **kwargs)[source]

Log a critical message.

Return type:

None

debug(message, *args, **kwargs)[source]

Log a debug message.

Return type:

None

disable_print_capture()[source]

Disable print statement capture.

Returns:

Self for method chaining

Return type:

Logger

enable_async_mode(queue_size=1000, flush_interval=1.0)[source]

Enable asynchronous logging mode.

Parameters:
  • queue_size (int) – Maximum size of the async queue

  • flush_interval (float) – Interval in seconds for flushing the queue

Returns:

Self for method chaining

Return type:

Logger

enable_print_capture()[source]

Enable print statement capture.

Returns:

Self for method chaining

Return type:

Logger

enable_visual_mode(use_symbols=True, use_indent=True)[source]

Enable visual formatting mode with symbols and indentation.

Parameters:
  • use_symbols (bool) – Whether to use Unicode symbols for log levels

  • use_indent (bool) – Whether to use visual indentation

Returns:

Self for method chaining

Return type:

Logger

error(message, *args, **kwargs)[source]

Log an error message.

Return type:

None

exception(message, *args, **kwargs)[source]

Log an exception message with traceback.

Return type:

None

info(message, *args, **kwargs)[source]

Log an info message.

Return type:

None

property logger: Logger

Get the underlying Python logger instance.

property name: str

Get the logger name without the logeverything prefix.

opt(colors=None, raw=None, depth=None, exception=None, lazy=None, ansi=None, record=None)[source]

Configure logging options (Loguru-style).

Parameters:
  • colors (Any) – Enable/disable colors in output

  • raw (Any) – Use raw output format

  • depth (Any) – Stack depth for caller information

  • exception (Any) – Include exception information

  • lazy (Any) – Use lazy evaluation

  • ansi (Any) – Enable/disable ANSI codes

  • record (Any) – Include record information

Returns:

A new logger instance with configured options

Return type:

Logger

Example

logger.opt(colors=True).info(“This is <green>colored</green> output”)

remove(handler_id=None)[source]

Remove a logging handler (Loguru-style).

Parameters:

handler_id (Any) – ID of handler to remove (if None, removes all)

Return type:

None

remove_handler(handler)[source]

Remove a logging handler.

Parameters:

handler (Handler) – The logging handler to remove

Return type:

None

set_level(level)[source]

Set the logging level.

Parameters:

level (Union[str, int]) – Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL or numeric)

Return type:

None

set_profile(profile_name)[source]

Apply a predefined configuration profile.

Parameters:

profile_name (str) – Name of the profile (development, production, testing, etc.)

Returns:

Self for method chaining

Return type:

Logger

warn(message, *args, **kwargs)[source]

Log a warning message (alias for warning).

Return type:

None

warning(message, *args, **kwargs)[source]

Log a warning message.

Return type:

None

logeverything.get_logger(name=None)[source]

Get a logger instance for the specified name with smart isolation.

Parameters:

name (Optional[str]) – The name for the logger

Returns:

The logger instance

Return type:

logging.Logger

logeverything.log(obj=None, using=None, **options)[source]

Smart unified decorator that automatically detects and applies appropriate logging.

This decorator will: - Apply async logging for async functions (coroutines) - Apply I/O logging for functions that perform I/O operations (if they match certain patterns) - Apply function logging for regular functions - Apply class logging for classes

Parameters:
  • obj (Union[TypeVar(F, bound= Callable), Type[TypeVar(T, bound= type)], None]) – The function or class to decorate

  • using (Optional[str]) – Name of the LogEverything Logger instance to use for logging

  • **options (Any) – Decorator options that override default configuration

Return type:

Union[TypeVar(F, bound= Callable), Type[TypeVar(T, bound= type)], Callable[[Union[TypeVar(F, bound= Callable), Type[TypeVar(T, bound= type)]]], Union[TypeVar(F, bound= Callable), Type[TypeVar(T, bound= type)]]]]

Returns:

The decorated function or class

logeverything.log_class(cls=None, using=None, **options)[source]

Class decorator that applies log_function to all methods in a class.

Parameters:
  • cls (Optional[Type]) – The class to decorate (automatically passed when used as @log_class)

  • using (Optional[str]) – Name of the LogEverything Logger instance to use for logging

  • **options (Any) – Decorator options that override default configuration

Return type:

Any

Returns:

The decorated class

logeverything.log_function(func=None, log_entry_exit=True, log_arguments=True, log_return_values=True, using=None, **options)[source]

Decorator for logging function entry and exit with arguments and return values.

Parameters:
  • func (Optional[TypeVar(F, bound= NamedCallable)]) – The function to decorate (automatically passed when used as @log_function)

  • log_entry_exit (bool) – Enable/disable logging of function entry and exit

  • log_arguments (bool) – Enable/disable logging of function arguments

  • log_return_values (bool) – Enable/disable logging of return values

  • using (Optional[str]) – Name of the LogEverything Logger instance to use for logging

  • **options (Any) – Additional decorator options

Return type:

Union[TypeVar(F, bound= NamedCallable), Callable[[TypeVar(F, bound= NamedCallable)], TypeVar(F, bound= NamedCallable)]]

Returns:

The decorated function

logeverything.log_io(func=None, using=None, **options)[source]

Decorator for logging I/O operations such as file access or network calls.

Parameters:
  • func (Optional[TypeVar(F, bound= NamedCallable)]) – The function to decorate (automatically passed when used as @log_io)

  • using (Optional[str]) – Name of the LogEverything Logger instance to use for logging

  • **options (Any) – Decorator options that override default configuration

Return type:

Union[TypeVar(F, bound= NamedCallable), Callable[[TypeVar(F, bound= NamedCallable)], TypeVar(F, bound= NamedCallable)]]

Returns:

The decorated function

Logger Class

LogEverything Logger Interface

This module provides a comprehensive, user-friendly logger interface that combines the power of LogEverything’s configuration system with an intuitive API.

Example usage:

from logeverything import Logger

# Simple usage with automatic setup
log = Logger()
log.info("Hello, world!")

# Advanced usage with custom configuration
log = Logger("my_app")
log.configure(
    level="DEBUG",
    visual_mode=True,
    handlers=["console", "file"],
    file_path="app.log"
)

# Contextual logging
with log.context("Data Processing"):
    log.info("Starting processing")
    log.debug("Loading data")
    log.warning("Some data missing")
    log.info("Processing complete")

# Bound context (similar to structured logging)
user_log = log.bind(user_id=123, request_id="abc-def")
user_log.info("User action performed")
class logeverything.logger.Logger(name=None, auto_setup=True, _register=True, **config)[source]

Bases: BaseLogger

A comprehensive logger interface for LogEverything.

This class provides a simple, powerful interface for logging that integrates all of LogEverything’s features while remaining easy to use.

Inherits from BaseLogger to provide a consistent API and enable extensibility.

__init__(name=None, auto_setup=True, _register=True, **config)[source]

Initialize the Logger with optional configuration.

Parameters:
  • name (Optional[str]) – Logger name (default: automatic based on caller)

  • auto_setup (bool) – Whether to automatically setup logging

  • _register (bool) – Whether to register this logger (internal parameter for bound loggers)

  • **config (Any) – Configuration options (level, visual_mode, handlers, etc.)

add(sink, **kwargs)[source]

Add a logging sink/handler (Loguru-style).

Parameters:
  • sink (Any) – File path, file object, or handler

  • **kwargs (Any) – Additional configuration options

Return type:

None

Example

logger.add(“file.log”, rotation=”500 MB”, retention=”10 days”) logger.add(sys.stderr, format=”{time} | {level} | {message}”)

add_file_logging(file_path, level=None)[source]

Add file logging to the logger.

Parameters:
  • file_path (str) – Path to the log file

  • level (Union[int, str, None]) – Logging level for the file (if different from main level)

Returns:

Self for method chaining

Return type:

Logger

add_handler(handler)[source]

Add a logging handler.

Parameters:

handler (Handler) – The logging handler to add

Return type:

None

configure(handlers=None, **kwargs)[source]

Configure the logger with LogEverything’s full configuration system.

Parameters:
  • handlers (Any) – List of handler configurations or names

  • **kwargs (Any) – Configuration options including: - level: Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL) - visual_mode: Enable visual formatting with symbols and indentation - use_symbols: Use Unicode symbols for log levels - use_indent: use visual indentation - use_colors: Enable colored log level indicators (default: True) - color_messages: Enable colored message text (default: False) - beautify: Enable beautiful formatting - file_path: File path for file logging - async_mode: Enable asynchronous logging - format: Custom log format string - And many more options from LogEverything’s configuration system

Returns:

Self for method chaining

Return type:

Logger

Examples:

# Simple configuration
log.configure(level="DEBUG", visual_mode=True)

# With message coloring control
log.configure(level="INFO", visual_mode=True, color_messages=True)

# Advanced configuration
log.configure(
    level="INFO",
    visual_mode=True,
    use_symbols=True,
    handlers=["console", "file"],
    file_path="app.log",
    async_mode=True
)

# Handler-specific configuration
log.configure(handlers=[
    {"name": "console", "level": "INFO"},
    {"name": "file", "level": "DEBUG", "file_path": "debug.log"}
])
context(context_name)[source]

Create a hierarchical logging context.

This creates a visual hierarchy in the logs, similar to how LogEverything’s decorators work but as a context manager.

Parameters:

context_name (str) – Name of the context to display in logs

Return type:

Iterator[None]

Example

with log.context(“Database Operation”):

log.info(“Connecting to database”) log.debug(“Executing query”) log.info(“Query completed”)

critical(message, *args, **kwargs)[source]

Log a critical message.

Return type:

None

debug(message, *args, **kwargs)[source]

Log a debug message.

Return type:

None

disable_print_capture()[source]

Disable print statement capture.

Returns:

Self for method chaining

Return type:

Logger

enable_async_mode(queue_size=1000, flush_interval=1.0)[source]

Enable asynchronous logging mode.

Parameters:
  • queue_size (int) – Maximum size of the async queue

  • flush_interval (float) – Interval in seconds for flushing the queue

Returns:

Self for method chaining

Return type:

Logger

enable_print_capture()[source]

Enable print statement capture.

Returns:

Self for method chaining

Return type:

Logger

enable_visual_mode(use_symbols=True, use_indent=True)[source]

Enable visual formatting mode with symbols and indentation.

Parameters:
  • use_symbols (bool) – Whether to use Unicode symbols for log levels

  • use_indent (bool) – Whether to use visual indentation

Returns:

Self for method chaining

Return type:

Logger

error(message, *args, **kwargs)[source]

Log an error message.

Return type:

None

exception(message, *args, **kwargs)[source]

Log an exception message with traceback.

Return type:

None

info(message, *args, **kwargs)[source]

Log an info message.

Return type:

None

property logger: Logger

Get the underlying Python logger instance.

property name: str

Get the logger name without the logeverything prefix.

opt(colors=None, raw=None, depth=None, exception=None, lazy=None, ansi=None, record=None)[source]

Configure logging options (Loguru-style).

Parameters:
  • colors (Any) – Enable/disable colors in output

  • raw (Any) – Use raw output format

  • depth (Any) – Stack depth for caller information

  • exception (Any) – Include exception information

  • lazy (Any) – Use lazy evaluation

  • ansi (Any) – Enable/disable ANSI codes

  • record (Any) – Include record information

Returns:

A new logger instance with configured options

Return type:

Logger

Example

logger.opt(colors=True).info(“This is <green>colored</green> output”)

remove(handler_id=None)[source]

Remove a logging handler (Loguru-style).

Parameters:

handler_id (Any) – ID of handler to remove (if None, removes all)

Return type:

None

remove_handler(handler)[source]

Remove a logging handler.

Parameters:

handler (Handler) – The logging handler to remove

Return type:

None

set_level(level)[source]

Set the logging level.

Parameters:

level (Union[str, int]) – Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL or numeric)

Return type:

None

set_profile(profile_name)[source]

Apply a predefined configuration profile.

Parameters:

profile_name (str) – Name of the profile (development, production, testing, etc.)

Returns:

Self for method chaining

Return type:

Logger

warn(message, *args, **kwargs)[source]

Log a warning message (alias for warning).

Return type:

None

warning(message, *args, **kwargs)[source]

Log a warning message.

Return type:

None

Base Logger

Base Logger Interface for LogEverything

This module provides the base logger class that all other loggers inherit from, ensuring a consistent API and enabling extensibility.

class logeverything.base.base_logger.BaseLogger(name)[source]

Bases: ABC

Base logger class that provides the foundation for all LogEverything loggers.

This abstract base class defines the common interface and behavior that all loggers must implement, ensuring consistency and enabling extensibility.

Users can inherit from this class to create custom logger implementations:

class CustomLogger(BaseLogger):
    def __init__(self, name: str):
        super().__init__(name)
        # Custom initialization

    def _log_message(self, level, message, *args, **kwargs):
        # Custom logging implementation
        pass
__del__()[source]

Cleanup when logger is deleted.

Unregisters the logger from the global registry to prevent memory leaks and stale references in decorator lookups.

Return type:

None

__enter__()[source]

Context manager entry.

Return type:

BaseLogger

__exit__(exc_type, exc_val, exc_tb)[source]

Context manager exit.

Only closes and cleans up system-created loggers. User-created loggers are left intact.

Return type:

None

__init__(name)[source]

Initialize the base logger.

Parameters:

name (str) – The name of the logger

__repr__()[source]

String representation of the logger.

Return type:

str

bind(**kwargs)[source]

Create a new logger instance with bound context data.

Following Loguru-style binding: bound loggers share the same name and underlying logger, with only context data being additive. This avoids registry pollution and maintains clean logger naming.

Parameters:

**kwargs (Any) – Context data to bind

Return type:

BaseLogger

Returns:

New logger instance with merged context (same name, additive context)

abstractmethod configure(**kwargs)[source]

Configure the logger with the specified parameters.

This method must be implemented by subclasses to handle logger-specific configuration.

Parameters:

**kwargs (Any) – Configuration parameters

Return type:

BaseLogger

Returns:

Self for method chaining

critical(message, *args, **kwargs)[source]

Log a critical message.

Return type:

None

debug(message, *args, **kwargs)[source]

Log a debug message.

Return type:

None

error(message, *args, **kwargs)[source]

Log an error message.

Return type:

None

exception(message, *args, **kwargs)[source]

Log an exception with traceback.

Return type:

None

fatal(message, *args, **kwargs)[source]

Alias for critical.

Return type:

None

get_config()[source]

Get the current configuration.

Return type:

Dict[str, Any]

info(message, *args, **kwargs)[source]

Log an info message.

Return type:

None

is_enabled_for(level)[source]

Check if logging is enabled for the given level.

Return type:

bool

property level: int

Get the current logging level.

log(level, message, *args, **kwargs)[source]

Log a message at the specified level.

Return type:

None

warn(message, *args, **kwargs)[source]

Alias for warning.

Return type:

None

warning(message, *args, **kwargs)[source]

Log a warning message.

Return type:

None

Global Configuration & Utilities

Core functionality for the LogEverything library.

This module provides the main configuration and setup functions for logging.

logeverything.core.configure(level=None, format=None, date_format=None, log_entry_exit=None, log_arguments=None, log_return_values=None, beautify=None, indent_level=None, handlers=None, logger_name=None, capture_print=None, print_logger_name=None, print_level=None, print_prefix=None, visual_mode=None, use_symbols=None, use_indent=None, align_columns=None, color_theme=None, async_mode=None, async_queue_size=None, async_flush_level=None, async_flush_interval=None, integrate_external_loggers=None, external_logger_level=None, _internal=False)[source]

Configure the logging system.

Parameters:
  • level (Union[int, str, None]) – Logging level (e.g., DEBUG, INFO).

  • format (Optional[str]) – Log format string (e.g., ‘%(asctime)s - %(name)s - %(levelname)s - %(message)s’).

  • date_format (Optional[str]) – Date format string for timestamps (e.g., ‘%Y-%m-%d %H:%M:%S’).

  • log_entry_exit (Optional[bool]) – Whether to log function entry and exit.

  • log_arguments (Optional[bool]) – Whether to log function arguments.

  • log_return_values (Optional[bool]) – Whether to log function return values.

  • beautify (Optional[bool]) – Whether to beautify logs with visual elements.

  • indent_level (Optional[int]) – Indentation level for beautified logs.

  • handlers (Optional[List[Union[str, Handler]]]) – List of handlers to use (e.g., [“console”, “file”]).

  • logger_name (Optional[str]) – Name of the logger to configure.

  • capture_print (Optional[bool]) – Whether to capture print statements.

  • print_logger_name (Optional[str]) – Logger name for captured print statements.

  • print_level (Optional[int]) – Logging level for captured print statements.

  • print_prefix (Optional[str]) – Prefix for captured print statements.

  • visual_mode (Optional[bool]) – Enable visual formatting with symbols and colors.

  • use_symbols (Optional[bool]) – Use Unicode symbols for log levels.

  • use_indent (Optional[bool]) – Use visual indentation with box drawing.

  • align_columns (Optional[bool]) – Align log columns for better readability.

  • color_theme (Optional[str]) – Color theme for visual formatting (‘default’, ‘pastel’, ‘bold’, ‘monochrome’).

  • async_mode (Optional[bool]) – Enable asynchronous logging (default: False).

  • async_queue_size (Optional[int]) – Maximum size of the async logging queue (default: 1000).

  • async_flush_level (Union[int, str, None]) – Log level that triggers immediate flush (default: CRITICAL).

  • async_flush_interval (Optional[float]) – Interval in seconds for flushing the async queue (default: 1.0).

  • integrate_external_loggers (Optional[bool]) – Whether to integrate with third-party loggers.

  • external_logger_level (Union[int, str, None]) – Logging level for external loggers.

Return type:

Dict[str, Any]

Returns:

A dictionary with the updated configuration.

Deprecated since version Use: Logger().configure() instead. This function will be removed in a future version.

logeverything.core.decrement_indent()[source]

Decrease the indentation level for the current execution context.

Note: This function now delegates to the unified IndentManager system.

Return type:

None

logeverything.core.detect_platform_capabilities()[source]

Detect the capabilities of the current platform for log formatting.

This function checks whether the current platform and terminal support Unicode characters and ANSI color codes.

Returns:

A dictionary with the platform capabilities

Return type:

Dict[str, Any]

logeverything.core.find_logger_for_decorator(requested_name=None, caller_info=None)[source]

Find an appropriate logger for decorator usage.

This function implements the smart logger selection logic for decorators: 1. If requested_name is provided, try to find that specific logger 2. If no specific logger requested but loggers exist, pick the first available 3. Check for standard Python loggers with handlers as fallback 4. If no loggers exist, create a temporary one

Parameters:
  • requested_name (Optional[str]) – Optional specific logger name to find

  • caller_info (Optional[str]) – Optional caller information for unique warning identification

Return type:

Any

Returns:

Logger instance to use

Raises:

ValueError – If a specific logger was requested but not found

logeverything.core.get_active_loggers()[source]

Get all currently active LogEverything Logger instances.

Return type:

Dict[str, Any]

Returns:

Dict mapping logger names to Logger instances

logeverything.core.get_current_indent()[source]

Get the current indentation string based on the execution context.

Returns:

The indentation string

Return type:

str

Note: This function now delegates to the unified IndentManager system.

logeverything.core.get_execution_id()[source]

Get the current execution ID (process-thread ID).

Returns:

The execution ID

Return type:

str

logeverything.core.get_function_stack()[source]

Get the current function call stack.

Returns:

The function call stack

Return type:

List[str]

logeverything.core.get_logger(name=None)[source]

Get a logger instance for the specified name with smart isolation.

Parameters:

name (Optional[str]) – The name for the logger

Returns:

The logger instance

Return type:

logging.Logger

logeverything.core.get_memory_usage()[source]

Get current memory usage statistics for LogEverything.

Return type:

Dict[str, int]

Returns:

Dictionary with cache sizes and memory usage info

logeverything.core.increment_indent()[source]

Increase the indentation level for the current execution context.

Note: This function now delegates to the unified IndentManager system.

Return type:

None

logeverything.core.pop_function()[source]

Remove the most recently added function from the execution stack.

Return type:

Optional[str]

Returns:

The function name that was removed, or None if the stack was empty

logeverything.core.push_function(func_name)[source]

Add a function to the execution stack.

Parameters:

func_name (str) – The name of the function

Return type:

None

logeverything.core.register_logger(name, logger_instance)[source]

Register an active LogEverything Logger instance.

This is called automatically when a Logger is created and allows decorators to find and use configured loggers.

Parameters:
  • name (str) – The logger name

  • logger_instance (Any) – The Logger instance

Return type:

None

logeverything.core.set_context_use_symbols(use_symbols)[source]

Set the use_symbols preference for indentation in the current thread context.

Return type:

None

logeverything.core.setup_logging(profile=None, level=None, format_string=None, handlers=None, file_path=None, log_directory=None, visual_mode=None, use_symbols=None, use_indent=None, align_columns=None, auto_detect_platform=None, force_ascii=None, disable_colors=None, color_theme=None, async_mode=None, async_queue_size=None, async_flush_level=None, async_flush_interval=None, integrate_external_loggers=None, external_logger_level=None, auto_detect_env=True, _internal=False, **kwargs)[source]

Set up logging with the specified configuration.

Parameters:
  • profile (Optional[str]) – Use a predefined configuration profile. Options: “development”, “production”, “minimal”, “debug”, “api”, “web”, “testing”. When specified, other parameters will override the profile defaults.

  • level (Union[int, str, None]) – The logging level to use (DEBUG, INFO, WARNING, ERROR, CRITICAL)

  • format_string (Optional[str]) – The format string for log messages

  • handlers (Optional[List[Union[str, Handler]]]) – List of handlers to use (“console”, “file”, “json”) or actual handler objects

  • file_path (Optional[str]) – Path to the log file if file handler is used

  • log_directory (Optional[str]) – Directory to store log files (will be created if it doesn’t exist)

  • visual_mode (Optional[bool]) – Enable enhanced visual formatting (default: False)

  • use_symbols (Optional[bool]) – Use Unicode symbols for log levels (default: False)

  • use_indent (Optional[bool]) – Use visual indentation with box drawing characters (default: False)

  • align_columns (Optional[bool]) – Align columns in log output (default: False)

  • auto_detect_platform (Optional[bool]) – Automatically detect platform capabilities (default: True)

  • force_ascii (Optional[bool]) – Force ASCII-only output (no Unicode) (default: False)

  • disable_colors (Optional[bool]) – Disable ANSI color codes (default: False)

  • color_theme (Optional[str]) – Color theme for console output (default: “default”)

  • async_mode (Optional[bool]) – Enable asynchronous logging (default: False)

  • async_queue_size (Optional[int]) – Size of the async logging queue (default: 1000)

  • async_flush_level (Union[int, str, None]) – Log level for immediate flush (default: CRITICAL)

  • async_flush_interval (Optional[float]) – Flush interval in seconds (default: 1.0)

  • integrate_external_loggers (Optional[bool]) – Enable external logger integration (default: False)

  • external_logger_level (Union[int, str, None]) – The logging level to use for external loggers (default: same as level)

  • auto_detect_env (bool) – Automatically detect the environment and apply

  • (default (optimized settings) – True)

  • **kwargs (Any) – Additional configuration options

Returns:

The configured logger

Return type:

logging.Logger

Note

When no specific configuration is provided and auto_detect_env is True, LogEverything will automatically configure itself based on the detected environment: - Web apps: Optimized for structured logs, async mode enabled, sensitive data protection - Notebooks: Visual enhanced output with symbols and indentation - CLI applications: Concise, direct output format - Scripts: Detailed debug information with timestamps and line numbers

Deprecated since version Use: Logger().configure() instead. This function will be removed in a future version.

logeverything.core.unregister_logger(name, instance=None)[source]

Unregister an active LogEverything Logger instance.

Parameters:
  • name (str) – The logger name to unregister

  • instance (Any) – Only unregister if the current instance matches

Return type:

None

Indent Manager

Unified Indent Manager for LogEverything.

This module provides a centralized, thread-safe, async-aware indentation system that replaces the separate sync/async indentation mechanisms throughout the codebase.

Key Features: - Unified API for sync and async contexts - Thread-local and context-variable support - Performance optimized with caching - Visual formatting with customizable symbols - Automatic sync/async detection - Context isolation for multiprocessing - Backward compatibility with existing APIs

class logeverything.indent_manager.IndentContext[source]

Bases: object

Thread-local and async-aware context for indentation tracking.

class logeverything.indent_manager.IndentManager[source]

Bases: object

Unified indentation manager that handles both sync and async contexts.

This manager automatically detects whether it’s running in a sync or async context and uses the appropriate storage mechanism (thread-local vs contextvar).

cleanup()[source]

Clean up cached data and contexts.

Return type:

None

configure(config)[source]

Configure the indent manager with global settings.

Parameters:

config (Dict[str, Any]) – Configuration dictionary from LogEverything

Return type:

None

context(levels=1)[source]

Context manager for temporary indentation level changes.

Parameters:

levels (int) – Number of levels to increment (can be negative)

Return type:

Iterator[IndentManager]

Example

with indent_manager.context(2):

# Code here is indented 2 levels deeper log_something()

current_call_id()[source]

Get the current (top) call ID without removing it.

Return type:

Optional[str]

decorator_enter(call_id)[source]

Compound: get_indent_string + push_call + increment. Single context lookup.

Used by decorators to replace three separate calls (each doing _get_context()) with a single context lookup.

Parameters:

call_id (str) – Unique call identifier for hierarchy tracking

Return type:

Tuple[str, IndentContext]

Returns:

Tuple of (indent_string, context)

decorator_exit()[source]

Compound: decrement + pop_call. Single context lookup.

Used by decorators to replace two separate calls (each doing _get_context()) with a single context lookup.

Return type:

None

decrement()[source]

Decrement indentation level.

Return type:

int

Returns:

New indentation level

decrement_async_indent()[source]

Backward compatibility: decrement async indentation.

Return type:

int

decrement_indent()[source]

Backward compatibility: decrement indentation.

Return type:

None

generate_call_id()[source]

Generate a locally-unique call ID using a monotonic counter.

Uses thread ID + counter for uniqueness without syscall overhead. Call IDs only need local uniqueness for hierarchy tracking.

Return type:

str

Returns:

Unique call ID string

get_async_indent()[source]

Backward compatibility: get async indentation level.

Return type:

int

get_current_indent()[source]

Backward compatibility: get current indentation string.

Return type:

str

get_execution_id()[source]

Get unique execution identifier for current context.

Return type:

str

Returns:

Unique execution ID string

get_hierarchy_snapshot()[source]

Return hierarchy fields with a single context lookup.

Used by HierarchyFilter to replace 4 separate method calls (get_level, current_call_id, parent_call_id, get_execution_id) each doing _get_context(), with a single lookup.

Return type:

Tuple[int, str, str, str]

Returns:

Tuple of (level, call_id, parent_call_id, execution_id)

get_indent_string(level=None, visual_mode=None, use_indent=None, use_symbols=None, force_ascii=None, indent_level=None)[source]

Get formatted indentation string.

Parameters:
  • level (Optional[int]) – Override indentation level (uses current if None)

  • visual_mode (Optional[bool]) – Enable visual mode formatting

  • use_indent (Optional[bool]) – Enable indentation in visual mode

  • use_symbols (Optional[bool]) – Enable symbol-based indentation

  • force_ascii (Optional[bool]) – Force ASCII characters

  • indent_level (Optional[int]) – Base indent level (spaces per level)

Return type:

str

Returns:

Formatted indentation string

get_level()[source]

Get current indentation level.

Return type:

int

Returns:

Current indentation level (integer)

increment()[source]

Increment indentation level.

Return type:

int

Returns:

New indentation level

increment_async_indent()[source]

Backward compatibility: increment async indentation.

Return type:

int

increment_indent()[source]

Backward compatibility: increment indentation.

Return type:

None

parent_call_id()[source]

Get the parent (second-to-top) call ID without removing it.

Return type:

Optional[str]

pop_call()[source]

Pop and return the top call ID from the call stack.

Return type:

Optional[str]

push_call(call_id)[source]

Push a call ID onto the call stack for hierarchy tracking.

Return type:

None

reset()[source]

Reset indentation level to 0.

Return type:

None

set_visual_preferences(use_symbols=None, visual_mode=None, use_indent=None, force_ascii=None)[source]

Set visual formatting preferences for current context.

Parameters:
  • use_symbols (Optional[bool]) – Whether to use Unicode symbols

  • visual_mode (Optional[bool]) – Enable visual mode

  • use_indent (Optional[bool]) – Enable indentation in visual mode

  • force_ascii (Optional[bool]) – Force ASCII characters

Return type:

None

logeverything.indent_manager.configure_indent_manager(config)[source]

Configure the global indent manager.

Return type:

None

logeverything.indent_manager.decrement_async_indent()[source]

Decrement async indentation level.

Return type:

int

logeverything.indent_manager.decrement_indent()[source]

Decrement indentation level.

Return type:

None

logeverything.indent_manager.get_async_indent()[source]

Get async indentation level.

Return type:

int

logeverything.indent_manager.get_current_indent()[source]

Get current indentation string.

Return type:

str

logeverything.indent_manager.get_indent_level()[source]

Get current indentation level.

Return type:

int

logeverything.indent_manager.get_indent_manager()[source]

Get the global indent manager instance.

Return type:

IndentManager

logeverything.indent_manager.increment_async_indent()[source]

Increment async indentation level.

Return type:

int

logeverything.indent_manager.increment_indent()[source]

Increment indentation level.

Return type:

None

logeverything.indent_manager.indent_context(levels=1)[source]

Context manager for temporary indentation.

Return type:

Any

logeverything.indent_manager.reset_indent()[source]

Reset indentation level to 0.

Return type:

None

logeverything.indent_manager.set_visual_preferences(**kwargs)[source]

Set visual formatting preferences.

Return type:

None

Decorators

LogEverything Decorators

This module provides decorators for automatically logging function calls, I/O operations, and class methods with minimal code changes.

Usage:

from logeverything.decorators import log, log_function, log_io, log_class

@log  # Smart decorator that auto-detects function vs I/O vs class
def my_function():
    pass

@log_function  # Explicit function logging
def my_function():
    pass

@log_io  # For I/O operations
def read_file(filename):
    pass

@log_class  # For class method logging
class MyClass:
    pass
logeverything.decorators.async_log_class(cls=None, using=None, **options)[source]

Decorator to apply async_log_function to all async methods in a class.

This decorator automatically wraps all coroutine methods in a class with the async_log_function decorator, while regular methods get the standard log_function decorator.

Parameters:
  • cls (Optional[Type]) – The class to decorate (automatically passed when used as @async_log_class)

  • using (Optional[str]) – Name of the LogEverything Logger instance to use for logging

  • **options (Any) – Decorator options that override default configuration

Return type:

Any

Returns:

The decorated class

logeverything.decorators.async_log_function(func=None, log_entry_exit=True, log_arguments=True, log_return_values=True, using=None, **options)[source]

Optimized decorator for logging entry, exit, and execution time of async functions.

Performance optimizations: - Fast path for disabled logging - Cached function metadata at decoration time - Reduced function call overhead - Optimized string building

Parameters:
  • func (Optional[TypeVar(F, bound= Callable[..., Any])]) – The async function to decorate (automatically passed when used as @async_log_function)

  • log_entry_exit (bool) – Enable/disable logging of function entry and exit

  • log_arguments (bool) – Enable/disable logging of function arguments

  • log_return_values (bool) – Enable/disable logging of return values

  • using (Optional[str]) – Name of the LogEverything Logger instance to use for logging

  • **options (Any) – Additional decorator options

Return type:

Union[TypeVar(F, bound= Callable[..., Any]), Callable[[TypeVar(F, bound= Callable[..., Any])], TypeVar(F, bound= Callable[..., Any])]]

Returns:

The decorated function

logeverything.decorators.log(obj=None, using=None, **options)[source]

Smart unified decorator that automatically detects and applies appropriate logging.

This decorator will: - Apply async logging for async functions (coroutines) - Apply I/O logging for functions that perform I/O operations (if they match certain patterns) - Apply function logging for regular functions - Apply class logging for classes

Parameters:
  • obj (Union[TypeVar(F, bound= Callable), Type[TypeVar(T, bound= type)], None]) – The function or class to decorate

  • using (Optional[str]) – Name of the LogEverything Logger instance to use for logging

  • **options (Any) – Decorator options that override default configuration

Return type:

Union[TypeVar(F, bound= Callable), Type[TypeVar(T, bound= type)], Callable[[Union[TypeVar(F, bound= Callable), Type[TypeVar(T, bound= type)]]], Union[TypeVar(F, bound= Callable), Type[TypeVar(T, bound= type)]]]]

Returns:

The decorated function or class

logeverything.decorators.log_async_class(cls=None, using=None, **options)

Decorator to apply async_log_function to all async methods in a class.

This decorator automatically wraps all coroutine methods in a class with the async_log_function decorator, while regular methods get the standard log_function decorator.

Parameters:
  • cls (Optional[Type]) – The class to decorate (automatically passed when used as @async_log_class)

  • using (Optional[str]) – Name of the LogEverything Logger instance to use for logging

  • **options (Any) – Decorator options that override default configuration

Return type:

Any

Returns:

The decorated class

logeverything.decorators.log_async_function(func=None, log_entry_exit=True, log_arguments=True, log_return_values=True, using=None, **options)

Optimized decorator for logging entry, exit, and execution time of async functions.

Performance optimizations: - Fast path for disabled logging - Cached function metadata at decoration time - Reduced function call overhead - Optimized string building

Parameters:
  • func (Optional[TypeVar(F, bound= Callable[..., Any])]) – The async function to decorate (automatically passed when used as @async_log_function)

  • log_entry_exit (bool) – Enable/disable logging of function entry and exit

  • log_arguments (bool) – Enable/disable logging of function arguments

  • log_return_values (bool) – Enable/disable logging of return values

  • using (Optional[str]) – Name of the LogEverything Logger instance to use for logging

  • **options (Any) – Additional decorator options

Return type:

Union[TypeVar(F, bound= Callable[..., Any]), Callable[[TypeVar(F, bound= Callable[..., Any])], TypeVar(F, bound= Callable[..., Any])]]

Returns:

The decorated function

logeverything.decorators.log_class(cls=None, using=None, **options)[source]

Class decorator that applies log_function to all methods in a class.

Parameters:
  • cls (Optional[Type]) – The class to decorate (automatically passed when used as @log_class)

  • using (Optional[str]) – Name of the LogEverything Logger instance to use for logging

  • **options (Any) – Decorator options that override default configuration

Return type:

Any

Returns:

The decorated class

logeverything.decorators.log_function(func=None, log_entry_exit=True, log_arguments=True, log_return_values=True, using=None, **options)[source]

Decorator for logging function entry and exit with arguments and return values.

Parameters:
  • func (Optional[TypeVar(F, bound= NamedCallable)]) – The function to decorate (automatically passed when used as @log_function)

  • log_entry_exit (bool) – Enable/disable logging of function entry and exit

  • log_arguments (bool) – Enable/disable logging of function arguments

  • log_return_values (bool) – Enable/disable logging of return values

  • using (Optional[str]) – Name of the LogEverything Logger instance to use for logging

  • **options (Any) – Additional decorator options

Return type:

Union[TypeVar(F, bound= NamedCallable), Callable[[TypeVar(F, bound= NamedCallable)], TypeVar(F, bound= NamedCallable)]]

Returns:

The decorated function

logeverything.decorators.log_io(func=None, using=None, **options)[source]

Decorator for logging I/O operations such as file access or network calls.

Parameters:
  • func (Optional[TypeVar(F, bound= NamedCallable)]) – The function to decorate (automatically passed when used as @log_io)

  • using (Optional[str]) – Name of the LogEverything Logger instance to use for logging

  • **options (Any) – Decorator options that override default configuration

Return type:

Union[TypeVar(F, bound= NamedCallable), Callable[[TypeVar(F, bound= NamedCallable)], TypeVar(F, bound= NamedCallable)]]

Returns:

The decorated function

Decorators for the LogEverything library.

This module provides decorators for automatically logging function calls, I/O operations, and class methods with minimal code changes.

Note: Some mypy errors in this file are related to complex decorator typing that represents limitations in Python’s type system rather than actual issues.

class logeverything.decorators.decorators.NamedCallable(*args, **kwargs)[source]

Bases: Protocol

logeverything.decorators.decorators.log_class(cls=None, using=None, **options)[source]

Class decorator that applies log_function to all methods in a class.

Parameters:
  • cls (Optional[Type]) – The class to decorate (automatically passed when used as @log_class)

  • using (Optional[str]) – Name of the LogEverything Logger instance to use for logging

  • **options (Any) – Decorator options that override default configuration

Return type:

Any

Returns:

The decorated class

logeverything.decorators.decorators.log_function(func=None, log_entry_exit=True, log_arguments=True, log_return_values=True, using=None, **options)[source]

Decorator for logging function entry and exit with arguments and return values.

Parameters:
  • func (Optional[TypeVar(F, bound= NamedCallable)]) – The function to decorate (automatically passed when used as @log_function)

  • log_entry_exit (bool) – Enable/disable logging of function entry and exit

  • log_arguments (bool) – Enable/disable logging of function arguments

  • log_return_values (bool) – Enable/disable logging of return values

  • using (Optional[str]) – Name of the LogEverything Logger instance to use for logging

  • **options (Any) – Additional decorator options

Return type:

Union[TypeVar(F, bound= NamedCallable), Callable[[TypeVar(F, bound= NamedCallable)], TypeVar(F, bound= NamedCallable)]]

Returns:

The decorated function

logeverything.decorators.decorators.log_io(func=None, using=None, **options)[source]

Decorator for logging I/O operations such as file access or network calls.

Parameters:
  • func (Optional[TypeVar(F, bound= NamedCallable)]) – The function to decorate (automatically passed when used as @log_io)

  • using (Optional[str]) – Name of the LogEverything Logger instance to use for logging

  • **options (Any) – Decorator options that override default configuration

Return type:

Union[TypeVar(F, bound= NamedCallable), Callable[[TypeVar(F, bound= NamedCallable)], TypeVar(F, bound= NamedCallable)]]

Returns:

The decorated function

Context Managers

Context managers for the LogEverything library.

This module provides context managers that allow for temporarily modifying logging configuration using Python’s with statement.

class logeverything.contexts.contexts.LoggingContext(level=None, log_entry_exit=None, log_arguments=None, log_return_values=None, beautify=None, indent_level=None, handlers=None, logger_name=None, capture_print=None, print_logger_name=None, print_level=None, print_prefix=None, **kwargs)[source]

Bases: object

A context manager for temporarily changing logging configuration.

This allows you to change logging settings within a specific block of code and automatically restore the previous settings when exiting the block.

Example

>>> with LoggingContext(level="DEBUG", log_entry_exit=True):
...     # Code here will use DEBUG level and log function entry/exit
...     my_function()
... # Original settings are restored after the with block
__enter__()[source]

Enter the context, save original settings and apply new ones.

Returns:

The current configuration

Return type:

Dict[str, Any]

__exit__(exc_type, exc_val, exc_tb)[source]

Exit the context and restore original settings.

Parameters:
  • exc_type (Any) – Exception type if an exception was raised

  • exc_val (Any) – Exception value if an exception was raised

  • exc_tb (Any) – Exception traceback if an exception was raised

Return type:

None

__init__(level=None, log_entry_exit=None, log_arguments=None, log_return_values=None, beautify=None, indent_level=None, handlers=None, logger_name=None, capture_print=None, print_logger_name=None, print_level=None, print_prefix=None, **kwargs)[source]

Initialize a logging context with temporary configuration.

Parameters:
  • level (Union[int, str, None]) – Temporarily change the logging level

  • log_entry_exit (Optional[bool]) – Whether to log function entry and exit

  • log_arguments (Optional[bool]) – Whether to log function arguments

  • log_return_values (Optional[bool]) – Whether to log function return values

  • beautify (Optional[bool]) – Whether to beautify logs with visual elements

  • indent_level (Optional[int]) – Indentation level for beautified logs

  • handlers (Optional[List[str]]) – List of handlers to use temporarily

  • logger_name (Optional[str]) – Name of the logger to configure

  • capture_print (Optional[bool]) – Whether to capture print statements

  • print_logger_name (Optional[str]) – Logger name for captured print statements

  • print_level (Optional[int]) – Logging level for captured print statements

  • print_prefix (Optional[str]) – Prefix for captured print statements

  • **kwargs (Any) – Additional configuration options

class logeverything.contexts.contexts.QuietLoggingContext(level=30, log_entry_exit=False, log_arguments=False, log_return_values=False, capture_print=False, **kwargs)[source]

Bases: LoggingContext

A context manager for temporarily suppressing or minimizing logging output.

This context manager is specialized for reducing log verbosity for a specific block of code, useful when you want to silence noisy operations temporarily.

Example

>>> with QuietLoggingContext():
...     # This code will produce minimal logs
...     noisy_operation()
... # Original logging verbosity is restored after the with block
__init__(level=30, log_entry_exit=False, log_arguments=False, log_return_values=False, capture_print=False, **kwargs)[source]

Initialize a quiet logging context with minimized verbosity.

Parameters:
  • level (Union[int, str]) – The logging level to use (defaults to WARNING)

  • log_entry_exit (bool) – Whether to log function entry and exit (defaults to False)

  • log_arguments (bool) – Whether to log function arguments (defaults to False)

  • log_return_values (bool) – Whether to log function return values (defaults to False)

  • capture_print (bool) – Whether to capture print statements (defaults to False)

  • **kwargs (Any) – Additional configuration options

class logeverything.contexts.contexts.TemporaryHandlerContext(handlers)[source]

Bases: object

A context manager for temporarily using specific log handlers.

This context manager allows you to temporarily switch to a different set of handlers for a specific block of code, and then automatically restore the original handlers when exiting the block.

Example

>>> with TemporaryHandlerContext(["file", "json"]):
...     # This code will log to file and JSON, ignoring console
...     important_operation()
... # Original handlers are restored after the with block
__enter__()[source]

Enter the context, save original handlers and apply new ones.

Returns:

The current configuration

Return type:

Dict[str, Any]

__exit__(exc_type, exc_val, exc_tb)[source]

Exit the context and restore original handlers.

Parameters:
  • exc_type (Any) – Exception type if an exception was raised

  • exc_val (Any) – Exception value if an exception was raised

  • exc_tb (Any) – Exception traceback if an exception was raised

Return type:

None

__init__(handlers)[source]

Initialize a temporary handler context.

Parameters:

handlers (List[Union[str, Handler]]) – A list of handler names or actual handler objects to use temporarily

class logeverything.contexts.contexts.VerboseLoggingContext(level=10, log_entry_exit=True, log_arguments=True, log_return_values=True, capture_print=True, **kwargs)[source]

Bases: LoggingContext

A context manager for temporarily increasing logging verbosity.

This context manager is specialized for maximizing log information for a specific block of code, useful for debugging or detailed analysis of specific operations.

Example

>>> with VerboseLoggingContext():
...     # This code will produce detailed logs
...     complex_operation()
... # Original logging verbosity is restored after the with block
__init__(level=10, log_entry_exit=True, log_arguments=True, log_return_values=True, capture_print=True, **kwargs)[source]

Initialize a verbose logging context with maximum verbosity.

Parameters:
  • level (Union[int, str]) – The logging level to use (defaults to DEBUG)

  • log_entry_exit (bool) – Whether to log function entry and exit (defaults to True)

  • log_arguments (bool) – Whether to log function arguments (defaults to True)

  • log_return_values (bool) – Whether to log function return values (defaults to True)

  • capture_print (bool) – Whether to capture print statements (defaults to True)

  • **kwargs (Any) – Additional configuration options

class logeverything.contexts.contexts.VisualLoggingContext(visual_mode=True, use_symbols=None, use_indent=None, align_columns=None, auto_detect_platform=None, force_ascii=None, disable_colors=None, color_theme=None, **kwargs)[source]

Bases: LoggingContext

A context manager for temporarily enabling or configuring visual logging.

This context manager is specialized for visual enhancements to logging output, allowing you to enable colors, symbols, indentation, and other visual elements for a specific block of code.

Visual settings are managed separately from standard logging settings because they may require reconfiguration of handlers and formatters. For this reason, they are handled through setup_logging() rather than configure().

Example

>>> with VisualLoggingContext(use_colors=True, use_symbols=True):
...     # Code here will use visual enhancements
...     log_complex_data()
... # Original visual settings are restored after the with block
__enter__()[source]

Enter the context, save original settings and apply new ones.

Returns:

The current configuration

Return type:

Dict[str, Any]

__exit__(exc_type, exc_val, exc_tb)[source]

Exit the context and restore original settings.

Parameters:
  • exc_type (Any) – Exception type if an exception was raised

  • exc_val (Any) – Exception value if an exception was raised

  • exc_tb (Any) – Exception traceback if an exception was raised

Return type:

None

__init__(visual_mode=True, use_symbols=None, use_indent=None, align_columns=None, auto_detect_platform=None, force_ascii=None, disable_colors=None, color_theme=None, **kwargs)[source]

Initialize a visual logging context with temporary configuration.

Parameters:
  • visual_mode (Optional[bool]) – Master switch for visual enhancements

  • use_symbols (Optional[bool]) – Whether to use Unicode symbols for log levels

  • use_indent (Optional[bool]) – Whether to use visual indentation with box drawing characters

  • align_columns (Optional[bool]) – Whether to align columns in log output

  • auto_detect_platform (Optional[bool]) – Whether to detect platform capabilities automatically

  • force_ascii (Optional[bool]) – Whether to force ASCII-only output (no Unicode)

  • disable_colors (Optional[bool]) – Whether to disable ANSI color codes

  • color_theme (Optional[str]) – Color theme to use for console output

  • **kwargs (Any) – Additional configuration options

Print Capture

LogEverything Print Capture

This module provides utilities for capturing and redirecting print statements and stdout. Includes high-performance print capture (7.9k ops/sec).

Usage:

from logeverything.capture import capture_print, enable_print_capture
from logeverything.capture import capture_stdout, restore_stdout

# Context manager for print capture
with capture_print(silent=True) as captured:
    print("This will be captured")
    output = captured.getvalue()

# Manual control
enable_print_capture()
print("This is captured")
disable_print_capture()
logeverything.capture.capture_print(logger_name='print', level=20, prefix='[PRINT] ')[source]

Context manager for capturing print statements.

Parameters:
  • logger_name (str) – Name of the logger to log output to

  • level (int) – Logging level to use

  • prefix (str) – Prefix to add to logged messages

Return type:

Any

Returns:

Context manager that captures print statements

logeverything.capture.capture_stdout(logger_name='stdout', level=20, prefix='[STDOUT] ')[source]

Capture all stdout output, not just print statements.

Parameters:
  • logger_name (str) – Name of the logger to log output to

  • level (int) – Logging level to use

  • prefix (str) – Prefix to add to logged messages

Return type:

TextIO

Returns:

Original stdout stream

logeverything.capture.disable_print_capture()[source]

Restore the original print function.

Return type:

None

logeverything.capture.enable_print_capture(logger_name='print', level=20, prefix='[PRINT] ')[source]

Enable print statement capturing.

Parameters:
  • logger_name (str) – Name of the logger to log output to

  • level (int) – Logging level to use

  • prefix (str) – Prefix to add to logged messages

Return type:

None

logeverything.capture.restore_stdout(original_stdout)[source]

Restore stdout to its original value.

Parameters:

original_stdout (TextIO) – Original stdout stream returned by capture_stdout

Return type:

None

Print capturing functionality for the logeverything package.

This module provides functions to capture print statements and redirect them to the logging system.

class logeverything.capture.print_capture.PrintCaptureStream(original_stream, logger_name='stdout', level=20, prefix='[PRINT] ')[source]

Bases: object

A stream class that captures writes and sends them to a logger.

__init__(original_stream, logger_name='stdout', level=20, prefix='[PRINT] ')[source]

Initialize a PrintCaptureStream.

Parameters:
  • original_stream (TextIO) – Original stream to forward writes to

  • logger_name (str) – Name of the logger to log output to

  • level (int) – Logging level to use

  • prefix (str) – Prefix to add to logged messages

property closed: bool

Return whether the original stream is closed.

flush()[source]

Flush the stream and log any remaining content.

Return type:

None

isatty()[source]

Return whether the original stream is a TTY.

Return type:

bool

property mode: str

Return the mode of the original stream.

property name: str

Return the name of the original stream.

write(text)[source]

Write text to the stream and log it.

Parameters:

text (str) – Text to write

Return type:

int

Returns:

Number of characters written

class logeverything.capture.print_capture.PrintFuncProtocol(*args, **kwargs)[source]

Bases: Protocol

logeverything.capture.print_capture.capture_print(logger_name='print', level=20, prefix='[PRINT] ')[source]

Context manager for capturing print statements.

Parameters:
  • logger_name (str) – Name of the logger to log output to

  • level (int) – Logging level to use

  • prefix (str) – Prefix to add to logged messages

Return type:

Any

Returns:

Context manager that captures print statements

logeverything.capture.print_capture.capture_stdout(logger_name='stdout', level=20, prefix='[STDOUT] ')[source]

Capture all stdout output, not just print statements.

Parameters:
  • logger_name (str) – Name of the logger to log output to

  • level (int) – Logging level to use

  • prefix (str) – Prefix to add to logged messages

Return type:

TextIO

Returns:

Original stdout stream

logeverything.capture.print_capture.disable_print_capture()[source]

Restore the original print function.

Return type:

None

logeverything.capture.print_capture.enable_print_capture(logger_name='print', level=20, prefix='[PRINT] ')[source]

Enable print statement capturing.

Parameters:
  • logger_name (str) – Name of the logger to log output to

  • level (int) – Logging level to use

  • prefix (str) – Prefix to add to logged messages

Return type:

None

logeverything.capture.print_capture.logging_print(*args, sep=' ', end='\\n', file=None, flush=False, **kwargs)[source]

Optimized replacement for the built-in print function that logs output with smart isolation.

Performance optimizations: - Cached logger instances with smart isolation (only when needed) - Bundled thread-local settings read (single getattr for settings tuple) - Cached handler enumeration (invalidates when handler count changes) - Direct _logger_cache lookup to skip _initialize_context() on cache hit - Fast path for silent mode (no console output) - Optimized string operations

Parameters:
  • *args (Any) – Values to print

  • sep (str) – Separator between values

  • end (str) – String to append after the last value

  • file (Optional[TextIO]) – File to write to

  • flush (bool) – Whether to forcibly flush the stream

  • **kwargs (Any) – Additional keyword arguments

Return type:

None

logeverything.capture.print_capture.restore_stdout(original_stdout)[source]

Restore stdout to its original value.

Parameters:

original_stdout (TextIO) – Original stdout stream returned by capture_stdout

Return type:

None

External Integration

External logger integration for the LogEverything library.

This module provides utilities for integrating third-party loggers with LogEverything, using Python’s standard logging mechanisms rather than complex wrapper classes.

logeverything.external.external.check_dependency(module_name, package_name=None)[source]

Check if an optional dependency is installed.

Parameters:
  • module_name (str) – The name of the module to import.

  • package_name (Optional[str]) – The name of the package to mention in error messages (if different from module_name).

Return type:

Tuple[bool, str]

Returns:

Tuple of (is_available, message). is_available is True if the dependency is available; message is empty when available or an error string when not.

logeverything.external.external.configure_common_loggers(additional_loggers=None, exclude_loggers=None, level=None, use_pretty_formatter=True, propagate=False, show_warnings=True)[source]

Automatically configure common third-party loggers.

Detects and configures common libraries’ loggers to use LogEverything’s formatting for consistent output.

Parameters:
  • additional_loggers (Optional[List[Union[str, Tuple[str, str]]]]) – Additional loggers to configure beyond the built-in list

  • exclude_loggers (Optional[List[str]]) – Loggers to exclude from configuration

  • level (Union[int, str, None]) – The log level to set for all loggers, or None to use the external_logger_level

  • use_pretty_formatter (bool) – Whether to apply LogEverything’s pretty formatting

  • propagate (bool) – Whether to allow loggers to propagate messages to parent loggers

  • show_warnings (bool) – Whether to show warnings for missing optional dependencies

Returns:

The names of the loggers that were configured

Return type:

List[str]

Examples

>>> # Configure all detected common loggers
>>> configure_common_loggers()
>>>
>>> # Configure common loggers plus custom ones
>>> configure_common_loggers(additional_loggers=['my_custom_lib'])
>>>
>>> # Configure common loggers except specific ones
>>> configure_common_loggers(exclude_loggers=['sqlalchemy'])
logeverything.external.external.configure_external_logger(logger_name, level=None, use_pretty_formatter=True, propagate=False)[source]

Configure a third-party logger to use LogEverything’s formatting and handling.

This function efficiently integrates external loggers with LogEverything’s configuration without creating complex wrappers or interceptors. It directly configures the logger using standard Python logging mechanisms.

Parameters:
  • logger_name (str) – The name of the logger to configure (e.g., ‘langchain’, ‘mlflow’)

  • level (Union[int, str, None]) – The log level to set, or None to use LogEverything’s default level

  • use_pretty_formatter (bool) – Whether to apply LogEverything’s pretty formatting

  • propagate (bool) – Whether to allow the logger to propagate messages to parent loggers

Returns:

The configured logger

Return type:

logging.Logger

Examples

>>> # Configure a third-party logger
>>> configure_external_logger('langchain', level='DEBUG')
>>>
>>> # Configure a logger with propagation to parent loggers
>>> configure_external_logger('uvicorn.access', propagate=True)
logeverything.external.external.harmonize_logger_levels(level=None, include_root=True, include_patterns=None, exclude_patterns=None)[source]

Set the same logging level for all detected loggers in the application.

This function helps ensure consistent logging levels across all loggers, which is especially useful when integrating with third-party libraries that may have their own logging settings.

Parameters:
  • level (Union[int, str, None]) – The log level to set for all loggers (None uses LogEverything’s level)

  • include_root (bool) – Whether to include the root logger (default: True)

  • include_patterns (Optional[List[str]]) – List of logger name patterns to include (e.g., [‘langchain.*’, ‘fastapi’])

  • exclude_patterns (Optional[List[str]]) – List of logger name patterns to exclude (e.g., [‘werkzeug.*’])

Returns:

Dictionary mapping logger names to their previous levels

Return type:

Dict[str, int]

Examples

>>> # Set all loggers to INFO level
>>> harmonize_logger_levels('INFO')
>>>
>>> # Set all loggers except the root logger to DEBUG
>>> harmonize_logger_levels('DEBUG', include_root=False)
>>>
>>> # Harmonize only specific loggers
>>> harmonize_logger_levels('WARNING', include_patterns=['uvicorn.*', 'fastapi'])
logeverything.external.external.intercept_stdlib(level=None, use_pretty_formatter=True)[source]

Install a LogEverything handler on the root stdlib logger. All stdlib loggers will now use LogEverything’s formatting.

Parameters:
  • level (Optional[int]) – Logging level (default: uses LogEverything config or INFO)

  • use_pretty_formatter (bool) – Whether to use PrettyFormatter (default: True)

Return type:

Any

Returns:

The intercept handler (for later removal if needed)

logeverything.external.external.restore_stdlib()[source]

Restore the root logger to its state before intercept_stdlib().

Return type:

None

Utility Modules

Utility functions for the LogEverything library.

This module provides common utility functions used across different modules.

class logeverything.utils.LoggingMetrics(total_calls=0, total_time=0.0, avg_time=0.0, max_time=0.0, min_time=inf, error_count=0, cache_hits=0, cache_misses=0)[source]

Bases: object

Metrics for logging performance monitoring.

avg_time: float = 0.0
cache_hits: int = 0
cache_misses: int = 0
error_count: int = 0
max_time: float = 0.0
min_time: float = inf
total_calls: int = 0
total_time: float = 0.0
class logeverything.utils.PerformanceMonitor(max_samples=1000)[source]

Bases: object

Monitor LogEverything performance metrics.

disable()[source]

Disable performance monitoring.

Return type:

None

enable()[source]

Enable performance monitoring.

Return type:

None

get_metrics()[source]

Get current performance metrics.

Return type:

Dict[str, Dict[str, Any]]

metrics: Dict[str, LoggingMetrics]
recent_times: Dict[str, deque]
record_call(operation, duration, error=False, cache_hit=False)[source]

Record a logging operation for performance monitoring.

Return type:

None

reset()[source]

Reset all metrics.

Return type:

None

logeverything.utils.format_value(value, max_length=300)[source]

Format a value for logging with proper truncation.

Parameters:
  • value (Any) – The value to format

  • max_length (int) – Maximum length before truncation

Returns:

The formatted value string

Return type:

str

logeverything.utils.get_ascii_only_mode()[source]
Return type:

bool

logeverything.utils.get_relative_path(absolute_path, base_path=None)[source]

Convert an absolute path to a relative path for cleaner log output.

Parameters:
  • absolute_path (str) – The absolute file path

  • base_path (Optional[str]) – Optional base path to calculate relative path from. If None, uses current working directory.

Returns:

Relative path from base directory, or just filename if outside base

Return type:

str

logeverything.utils.get_symbols()[source]
Return type:

Dict[str, str]

logeverything.utils.safe_float(val, default)[source]

Safely convert a value to float with a default.

Parameters:
  • val (Any) – The value to convert

  • default (float) – Default value if conversion fails

Returns:

The converted float or default value

Return type:

float

logeverything.utils.safe_int(val, default)[source]

Safely convert a value to int with a default.

Parameters:
  • val (Any) – The value to convert

  • default (int) – Default value if conversion fails

Returns:

The converted integer or default value

Return type:

int

logeverything.utils.supports_unicode()[source]
Return type:

bool

Logging levels for LogEverything.

Formatting utility functions for the LogEverything library.

logeverything.utils.format_utils.format_value(value, max_length=300)[source]

Format a value for logging with proper truncation.

Parameters:
  • value (Any) – The value to format

  • max_length (int) – Maximum length before truncation

Returns:

The formatted value string

Return type:

str

logeverything.utils.format_utils.safe_float(val, default)[source]

Safely convert a value to float with a default.

Parameters:
  • val (Any) – The value to convert

  • default (float) – Default value if conversion fails

Returns:

The converted float or default value

Return type:

float

logeverything.utils.format_utils.safe_int(val, default)[source]

Safely convert a value to int with a default.

Parameters:
  • val (Any) – The value to convert

  • default (int) – Default value if conversion fails

Returns:

The converted integer or default value

Return type:

int

logeverything.utils.platform_utils.clear_symbol_cache()[source]
Return type:

None

logeverything.utils.platform_utils.get_ascii_only_mode()[source]
Return type:

bool

logeverything.utils.platform_utils.get_platform_symbols()[source]
Return type:

Dict[str, Any]

logeverything.utils.platform_utils.get_symbols()[source]
Return type:

Dict[str, str]

logeverything.utils.platform_utils.is_windows_terminal()[source]
Return type:

bool

logeverything.utils.platform_utils.supports_unicode()[source]
Return type:

bool