Skip to main content
LogTape structures logs with a category system. Sonamu automatically generates categories for Model, Frame, Workflow, and Agent classes.

What is a Category?

A category represents the source of logs in a hierarchical structure. Format: ["a", "b", "c"] array Examples:
  • ["fastify"] - Fastify framework
  • ["sonamu", "model", "user-model"] - UserModel class
  • ["sonamu", "workflow", "email-send"] - EmailSendWorkflow
  • ["app", "payment", "processor"] - Custom category

Purpose of the Category System

Categories are needed to systematically manage logs. 1. Log Source Identification
2. Selective Logging
3. Separate Log Storage

Benefits of Hierarchical Structure

Why categories are hierarchical: 1. Clear Structure
You can see at a glance where a log originated 2. Flexible Filtering
3. Collision Prevention

Why Only Exact Matching?

LogTape only matches categories that exactly match.
Reasons:
  1. Clarity
  1. Performance
  1. Predictability

Category Structure Details

Hierarchy Representation

Categories narrow down progressively.
Configuration example:

Category Matching

LogTape only matches categories that exactly match.

Automatic Category Generation

Sonamu automatically generates categories for specific classes.

Model Classes

Conversion rules:
  1. Remove ModelClass from class name
  2. Convert PascalCase β†’ snake_case
  3. Convert snake_case β†’ kebab-case
Examples:

Frame Classes

Conversion rules: Same as Model but removes FrameClass

Workflow

Conversion rules:
  1. Remove Workflow from class name (suffix only)
  2. Convert PascalCase β†’ snake_case
  3. Convert snake_case β†’ kebab-case
Examples:

Agent Classes

Conversion rules: Same as Model but removes AgentClass

Naite Categories

Naite test keys follow special category conversion rules.
Conversion rules:
  1. Split by .
  2. Split each part by :
  3. Flatten
Examples:

Category-Based Logging Configuration

Separate Logs by Model

Adjust Log Levels by Type

Management by Namespace

Custom Categories

You can use custom categories in application code.
Configuration:

Practical Examples

Development Environment Detailed Logging

Production Selective Logging

Log Separation by Domain

Internal Operation Principles

This section explains how Sonamu’s category system works internally. The functions shown here are used automatically by Sonamu and cannot be called directly by users.

isSameCategory()

An internal function that checks if two categories match exactly.
Internal use: Used when matching categories in LogTape’s logger configuration.

convertDomainToCategory()

An internal function that converts class names to categories.
Internal use: Automatically assigns categories when Model, Frame, Workflow, and Agent classes are created. Conversion logic:
  1. Remove suffix from class name (ModelClass, FrameClass, AgentClass, Workflow)
  2. Convert PascalCase β†’ snake_case
  3. Convert snake*case β†’ kebab-case (*β†’-)
  4. Compose as ["sonamu", type, name] format

convertNaiteKeyToCategory()

An internal function that converts Naite test keys to categories.
Internal use: Automatically generates log categories when running Naite tests. Conversion logic:
  1. Split by .
  2. Split each part by :
  3. Flatten

Important Notes

1. Only Exact Matching Supported

2. Categories are readonly Arrays

3. Class Naming Conventions

4. Fastify Category Duplication

Next Steps

Fastify Logging

Customize HTTP request/response logging

Sinks & Filters

Control log output with custom Sinks and Filters

LogTape Setup

Learn basic logging configuration and concepts

LogTape Official Documentation

Check LogTape’s advanced features and APIs