Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:AMAP ML SkillClaw Colorized Logging

From Leeroopedia
Knowledge Sources
Domains Logging, Developer_Experience
Last Updated 2026-10-22 00:00 GMT

Overview

A logging formatting principle that applies context-aware ANSI color codes to terminal log output based on component identity, log level, and message content patterns, improving visual debuggability of complex multi-component daemon systems.

Description

Colorized Logging addresses the readability problem in systems with many concurrent components writing to the same log stream. In SkillClaw, components like the API proxy, skill manager, PRM scorer, trainer, OpenClaw agent, and evolve engine all log simultaneously. Without color coding, distinguishing which component produced a line requires reading the logger name field carefully. Colorized Logging solves this by assigning each component a distinct ANSI color and applying additional visual emphasis (bold) for important message patterns. The formatter parses the structured log line, identifies the source component, and wraps the message in appropriate ANSI escape sequences. Color is applied only when stdout is a TTY, ensuring log files remain plain text.

Usage

Use this principle when:

  • Designing logging for multi-component daemon systems with interleaved output
  • Components need visual distinction in terminal output (color by component)
  • Important message patterns need emphasis (bold for actions like POST, skill injection)
  • Log output should be plain text when redirected to files (TTY detection)
  • Debugging requires rapid visual scanning of log streams

Theoretical Basis

The core mechanism is pattern-based color assignment:

# Abstract algorithm description (NOT real implementation)

def colorize(log_line, level, logger_name, message):
    # 1. Check content-specific patterns first (highest priority)
    if "[SkillManager]" in message:
        return bold(magenta(message))
    if "[Trainer]" in message:
        return bold(blue(message))

    # 2. Fall back to logger-name-based coloring for INFO level
    if level == "INFO":
        color = map_logger_to_color(logger_name)
        return bold(color(message))

    # 3. Fall back to level-based coloring
    level_colors = {"WARNING": yellow, "ERROR": red, "DEBUG": magenta}
    return bold(level_colors.get(level, default)(message))

# TTY detection gates all color application
if not sys.stdout.isatty():
    return plain_text  # no ANSI codes in log files

Priority order: content pattern → logger name → log level. This ensures the most specific visual cue wins.

Related Pages

Page Connections

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