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:InternLM Lmdeploy Logger

From Leeroopedia


Knowledge Sources
Domains Infrastructure, Logging
Last Updated 2026-02-07 15:00 GMT

Overview

Singleton logging interface with five severity levels (TRACE, DEBUG, INFO, WARNING, ERROR) and printf-style formatting, used throughout TurboMind.

Description

The Logger class is a singleton providing the standard logging interface for all TurboMind components. It supports five log levels: TRACE (0), DEBUG (10), INFO (20), WARNING (30), and ERROR (40). The default level is DEBUG in debug builds and INFO in release builds. Messages are formatted using printf-style variadic templates via fmtstr() and written to stderr with a [TM][LEVEL] prefix. An overloaded log() variant accepts a rank parameter for multi-GPU logging with [TM][LEVEL][rank] prefix. Convenience macros TM_LOG_TRACE, TM_LOG_DEBUG, TM_LOG_INFO, TM_LOG_WARNING, and TM_LOG_ERROR provide level-checked logging with short-circuit evaluation to avoid formatting overhead when the level is below threshold.

Usage

Use the TM_LOG_* macros for all logging throughout TurboMind. Set the log level via Logger::getLogger().setLevel() to control verbosity.

Code Reference

Source Location

Signature

class Logger {
public:
    enum Level { TRACE = 0, DEBUG = 10, INFO = 20, WARNING = 30, ERROR = 40 };

    static Logger& getLogger();

    template<typename... Args>
    void log(const Level level, const std::string format, const Args&... args);

    template<typename... Args>
    void log(const Level level, const int rank, const std::string format, const Args&... args);

    void setLevel(const Level level);
    int getLevel() const;
};

#define TM_LOG_TRACE(...)   TM_LOG(turbomind::Logger::TRACE, __VA_ARGS__)
#define TM_LOG_DEBUG(...)   TM_LOG(turbomind::Logger::DEBUG, __VA_ARGS__)
#define TM_LOG_INFO(...)    TM_LOG(turbomind::Logger::INFO, __VA_ARGS__)
#define TM_LOG_WARNING(...) TM_LOG(turbomind::Logger::WARNING, __VA_ARGS__)
#define TM_LOG_ERROR(...)   TM_LOG(turbomind::Logger::ERROR, __VA_ARGS__)

Import

#include "src/turbomind/utils/logger.h"

I/O Contract

Inputs

Name Type Required Description
level Logger::Level Yes Severity level for the log message
format std::string Yes Printf-style format string
args variadic No Format arguments
rank int No GPU/process rank for multi-GPU prefix

Outputs

Name Type Description
Log output stderr Formatted log message written to stderr

Usage Examples

using namespace turbomind;

// Basic logging
TM_LOG_INFO("Model loaded with %d layers, hidden_dim=%d", num_layers, hidden_dim);
TM_LOG_WARNING("Batch size %d exceeds recommended maximum", batch_size);
TM_LOG_ERROR("Failed to allocate %zu bytes", required_bytes);

// Multi-GPU logging with rank
Logger::getLogger().log(Logger::INFO, rank, "Device %d ready", device_id);

// Set log level
Logger::getLogger().setLevel(Logger::DEBUG);

Related Pages

Page Connections

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