All production logs must go through LOG_INFO, LOG_WARN, or LOG_ERROR from src/utils/log.hpp.
The emitted format is:
LEVEL_code: username/index_name: message
LEVEL: username/index_name: message
LEVELis one ofINFO,WARN, orERROR.codeis an explicit numeric message code when present.username/index_nameidentifies the user and index tied to the event.- If a log is not tied to a specific index, placeholders are used:
- global log:
-/- - user-only log:
username/-
- global log:
Examples:
INFO_2023: alice/catalog: Starting reload
WARN_1035: alice/catalog: Invalid k: 0
ERROR_1502: alice/catalog: Failed to store metadata: MDBX_MAP_FULL
INFO: -/-: Starting the server
WARN_1064: alice/-: Backup-info request for missing backup nightly
INFO_1703: -/-: NEON is supported and usable
The same macros are used everywhere. The implementation decides how to build context from the arguments:
LOG_INFO("Starting the server");
LOG_WARN(1058, username, "Backup download requested for missing backup " << backup_name);
LOG_ERROR(2039, index_id, "Search failed: " << e.what());
LOG_INFO(2045, username, index_name, "Restored backup from " << backup_tar);Supported forms:
LOG_INFO(message)
LOG_INFO(code, message)
LOG_INFO(code, context, message)
LOG_INFO(code, username, index_name, message)The same overload shapes apply to LOG_WARN and LOG_ERROR.
LOG_*(message)- Global log.
- Context becomes
-/-. - No numeric code is emitted.
LOG_*(code, message)- Global log with explicit code.
LOG_*(code, context, message)- If
contextcontains/, it is treated asindex_idand split intousername/index_name. - Otherwise it is treated as
usernameand becomesusername/-.
- If
LOG_*(code, username, index_name, message)- Uses the explicit username and index name directly.
- Explicit numeric codes are preferred for stable operational logs.
- Code-less logs are valid and must never receive synthesized IDs.
- Prefer logging at request boundaries, lifecycle transitions, and rare failure paths.
- Do not add logs in hot loops or per-vector/per-result paths.
- Replace
std::cerrwithLOG_*so the output format stays consistent. - For index-scoped code, prefer passing
index_idand logging withLOG_*(code, index_id, ...). - Keep messages short and problem-oriented. Include values that help debug the failure.
- Reuse the existing local code range in the file you are editing when extending current behavior.
- Keep related code ranges grouped by subsystem when practical:
1000srequest/server logs1200sfilter logs1300sbackup store logs1400sWAL logs1500smetadata logs1600svector storage logs1700sCPU compatibility logs2000sindex manager logs2100sHNSW load/cache logs
- Macro dispatch and formatting live in src/utils/log.hpp.
- Request-level validation and 500 logging live in src/main.cpp.
- Index lifecycle and persistence logs live in src/core/ndd.hpp.