Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:BerriAI Litellm Custom Logger Registry

From Leeroopedia
Revision as of 12:09, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/BerriAI_Litellm_Custom_Logger_Registry.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Attribute Value
Sources litellm/litellm_core_utils/custom_logger_registry.py
Domains Logging, Callbacks, Integrations
Last Updated 2026-02-15 16:00 GMT

Overview

Central registry that maps callback name strings (e.g., "datadog", "prometheus") to their corresponding logger class types.

Description

The CustomLoggerRegistry class maintains a class-level dictionary CALLBACK_CLASS_STR_TO_CLASS_TYPE that associates short string identifiers with logger/callback class implementations. It covers over 30 integrations including DataDog, Prometheus, Langfuse, OpenTelemetry, GCS, Argilla, Opik, and many more. Multiple string identifiers can map to the same class (e.g., "logfire", "arize", "otel" all map to OpenTelemetry). Enterprise loggers (PagerDuty, GenericAPI, email loggers) are conditionally added if the litellm_enterprise package is installed. The class provides methods for bidirectional lookup: string-to-class and class-to-string(s).

Usage

Import this registry when you need to resolve a callback name string from configuration to its actual class, or when you need to discover which string identifier(s) correspond to a logger class. This is used internally by LiteLLM's callback initialization pipeline.

Code Reference

Source Location

litellm/litellm_core_utils/custom_logger_registry.py (178 lines)

Signature

class CustomLoggerRegistry:
    CALLBACK_CLASS_STR_TO_CLASS_TYPE: dict  # str -> type

    @classmethod
    def get_callback_str_from_class_type(cls, class_type: type) -> Union[str, None]

    @classmethod
    def get_all_callback_strs_from_class_type(cls, class_type: type) -> list[str]

    @classmethod
    def get_class_type_for_custom_logger_name(
        cls,
        custom_logger_name: _custom_logger_compatible_callbacks_literal,
    ) -> type

Import

from litellm.litellm_core_utils.custom_logger_registry import CustomLoggerRegistry

I/O Contract

get_callback_str_from_class_type

Direction Name Type Description
Input class_type type Logger class to look up
Output return Union[str, None] First matching callback string, or None

get_all_callback_strs_from_class_type

Direction Name Type Description
Input class_type type Logger class to look up
Output return list[str] All callback strings mapping to this class

get_class_type_for_custom_logger_name

Direction Name Type Description
Input custom_logger_name _custom_logger_compatible_callbacks_literal String identifier for the logger
Output return type The class type for the named logger

Usage Examples

from litellm.litellm_core_utils.custom_logger_registry import CustomLoggerRegistry
from litellm.integrations.opentelemetry import OpenTelemetry

# Resolve a callback string to its class
cls = CustomLoggerRegistry.get_class_type_for_custom_logger_name("datadog")
# cls == DataDogLogger

# Find the string for a class
name = CustomLoggerRegistry.get_callback_str_from_class_type(OpenTelemetry)
# name == "opentelemetry" (first match)

# Find all strings that map to OpenTelemetry
all_names = CustomLoggerRegistry.get_all_callback_strs_from_class_type(OpenTelemetry)
# ["opentelemetry", "logfire", "arize", "langfuse_otel", "arize_phoenix", "langtrace", "weave_otel", "levo", "otel"]

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment