用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/skills-registry --skill mellea-logging命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
| Use when this capability is needed.
> Use when this capability is needed.
Review architecture and API design for the vfs-s3 project. Use when the user mentions @architect, asks to review an issue's design, discuss module boundaries, API shape, or architectural decisions for vfs-s3. Also trigger when the user wants to create an ADR (Architecture Decision Record) or evaluate a technical approach for the project. Intended for dispatch from Codex automation or Claude routines; GitHub trigger phrase: @vfs-s3-bot please prepare design doc Use when this capability is needed.
基于 SOC 职业分类
正在显示 SKILL.md
| name | mellea-logging |
| description | > Use when this capability is needed. |
All logging in Mellea flows through MelleaLogger.get_logger(), defined in
mellea/core/utils.py. This skill documents the conventions for adding and
reviewing log instrumentation.
from mellea.core import MelleaLogger, log_context, set_log_context, clear_log_context
logger = MelleaLogger.get_logger()
# Dedicated log call — for a discrete event
logger.info("SUCCESS")
# Context injection — attach fields to every record in a scope
with log_context(request_id="req-abc", trace_id="t-1"):
logger.info("Starting generation") # includes request_id, trace_id
# ... all nested calls inherit these fields automatically
Use logger.info/warning/error(...) for discrete, named events:
| Event type | Level | Example |
|---|---|---|
| Phase transition | INFO | "SUCCESS", "FAILED", "Starting session" |
| Loop progress | INFO | "Running loop 2 of 3" |
| Recoverable issue | WARNING | "Warmup failed for model: ..." |
| Unexpected failure | ERROR | exception tracebacks, hard failures |
| Verbose diagnostics | DEBUG | token counts, prompt previews |
Do not add log calls for:
log_context field (redundant noise)Use log_context (or set_log_context) to attach identifiers and metadata
that should appear on every log record within a scope — without threading
them through every call.
Typical injection points:
| Scope | Where to inject | Fields |
|---|---|---|
| Session lifetime | MelleaSession.__enter__ | session_id, backend, model_id |
| Sampling loop | BaseSamplingStrategy.sample() | strategy, loop_budget |
| HTTP request handler | entry point of the handler | request_id, trace_id |
| Background task | top of the task coroutine | task_id, job_name |
Use these names consistently. Do not invent synonyms.
| Field | Type | Description |
|---|---|---|
session_id | str (UUID) | Unique ID for a MelleaSession |
backend | str | Backend class name, e.g. "OllamaModelBackend" |
model_id | str | Model identifier string |
strategy | str | Sampling strategy class name |
loop_budget | int | Max generate/validate cycles for this sampling call |
request_id | str | Caller-supplied request identifier |
trace_id | str | Distributed trace ID (from OpenTelemetry or caller) |
span_id | str | Span ID within a trace |
user_id | str | End-user identifier (when applicable) |
The following names are standard logging.LogRecord attributes. Passing them
to log_context() or set_log_context() raises ValueError. See
RESERVED_LOG_RECORD_ATTRS in mellea/core/utils.py for the full set.
args, created, exc_info, exc_text, filename, funcName,
levelname, levelno, lineno, message, module, msecs, msg,
name, pathname, process, processName, relativeCreated,
stack_info, thread, threadName
# Preferred — guaranteed cleanup even on exceptions
with log_context(trace_id="abc"):
do_work()
# Acceptable only when lifetime equals __enter__/__exit__
# (e.g. MelleaSession, where the CM already guarantees cleanup)
set_log_context(session_id=self.id)
# ... later in __exit__ ...
clear_log_context()
The context manager uses a ContextVar token to restore the previous state
on exit. This means nesting works correctly — inner calls can add fields
without clobbering the outer scope's values.
log_context uses contextvars.ContextVar, which is safe for concurrent
asyncio tasks:
asyncio.Task gets its own copy of the context.Plugin hooks: Mellea hooks (AUDIT, SEQUENTIAL, CONCURRENT) are
awaited in the same asyncio task as the call site. ContextVar state IS
inherited — fields set around a strategy.sample() call will appear on
records emitted inside hook handlers automatically.
MelleaLogger.get_logger(), not logging.getLogger(...).log_context.with log_context(...), not set_log_context (unless
managing an __enter__/__exit__ pair).logger.info(...) call.Source: generative-computing/mellea — distributed by TomeVault.