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 IdentificationBenefits of Hierarchical Structure
Why categories are hierarchical: 1. Clear StructureWhy Only Exact Matching?
LogTape only matches categories that exactly match.- Clarity
- Performance
- Predictability
Category Structure Details
Hierarchy Representation
Categories narrow down progressively.Category Matching
LogTape only matches categories that exactly match.Automatic Category Generation
Sonamu automatically generates categories for specific classes.Model Classes
- Remove
ModelClassfrom class name - Convert PascalCase β snake_case
- Convert snake_case β kebab-case
Frame Classes
FrameClass
Workflow
- Remove
Workflowfrom class name (suffix only) - Convert PascalCase β snake_case
- Convert snake_case β kebab-case
Agent Classes
AgentClass
Naite Categories
Naite test keys follow special category conversion rules.- Split by
. - Split each part by
: - Flatten
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.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.convertDomainToCategory()
An internal function that converts class names to categories.- Remove suffix from class name (
ModelClass,FrameClass,AgentClass,Workflow) - Convert PascalCase β snake_case
- Convert snake*case β kebab-case (
*β-) - Compose as
["sonamu", type, name]format
convertNaiteKeyToCategory()
An internal function that converts Naite test keys to categories.- Split by
. - Split each part by
: - 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