Enforce Magic Web structured business error logging when adding, changing, migrating, or reviewing `logger.error` calls in `src`, `enterprise/src`, or `customer/src`, including catch blocks, callbacks, ErrorBoundaries, workers, WebSocket/storage flows, and logger adapters. Use to choose `eventKey/errorKind/error/message/context`, preserve historical diagnostics, prevent unsafe payloads, and verify the JS probe plus `/log-report` behavior.
77
97%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
Apply the current structured error protocol without changing the business workflow or losing diagnostic evidence.
Read the current implementation before changing logging behavior:
src/utils/log/errorReport.tssrc/utils/log/Logger.tssrc/utils/log/plugins/builtin/ReporterPlugin/ReporterPlugin.tspackages/logger/src/providers/volcengine/error.tsWhen source layers are involved, inspect src, enterprise/src, and customer/src; follow the active overlay instead of assuming src is the only implementation.
Read references/contract.md when deciding field behavior, Provider visibility, serialization, or sensitive-data boundaries. Read references/examples.md when migrating legacy calls, handling callbacks, or reviewing a proposed log change.
src/utils/log, not console, a third-party callback logger, Bridge logger, test double, or unrelated object with an error method.createLogContext, PPT/recording adapters, and message-context builders.eventKey.errorKind supported by evidence.error.message.context with meaningful keys.error, or an unbounded object.Use one structured object:
logger.error({
eventKey: "stable_failure_event",
errorKind: "network",
error,
message: "Historical or stable business error description",
context: {
operation: "load",
},
})eventKey and errorKind are required non-empty strings. error, message, and context are optional only when the business scenario genuinely has no corresponding value.
Never pass namespace, eventId, release, or captureSource; the Logger supplies them. Do not add a new business logging method or change POST /log-report.
eventKeysnake_case._failed, _timeout, _unsupported, _missing, _exhausted, or _anomaly.upload_batch_batch_upload_failed.errorKindPrefer the current vocabulary:
network storage render permission worker lifecycle timeout
invalid_state quota parse database unknownUse unknown when evidence does not support a narrower category. Do not infer categories from arbitrary error text.
errorError object whenever available.Error in business code only for logging.error.message when the original object exists.message and stack in context; the bottom layer handles a real Error.messageerror or named context fields.Error controls the fire-probe exception message; the self-hosted record preserves both fields independently.contexterror or message when those fields are already separate.errorType in context while placing the actual error value in top-level error.args.find(...) when a typed Error parameter exists.StructuredErrorInput; enrich only the adapter-owned context and do not rewrite caller fields.When reviewing logging changes, prioritize findings in this order:
Error or non-Error failure value was dropped or replaced.eventKey is dynamic, ambiguous, duplicated, or semantically misleading.errorKind is unsupported by the actual failure.Treat wording-only changes as acceptable when no diagnostic information is lost.
Perform checks proportional to the change:
rg -n "logger\.error" <touched-files>
corepack pnpm exec vitest run --config ./vitest.config.ts <focused-tests>
git diff --checkAlso verify manually:
Complete only when the new call is structurally valid, preserves all justified historical diagnostics, excludes only clearly unsafe or unbounded data, keeps business behavior unchanged, and passes focused verification.
dtyq/magic
f9973c5
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.