diagnostic-logs

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Diagnostic Logs

诊断日志

Format

格式

typescript
console.log('[IDENTIFIER] Clear purpose message', JSON.stringify({ object: data }));
typescript
console.log('[IDENTIFIER] Clear purpose message', JSON.stringify({ object: data }));

Requirements

要求

  1. Clear purpose - What is this log telling you?
  2. Single filterable identifier -
    [UPPER_CASE]
    prefix (e.g.,
    [THUMB_STRIP]
    ,
    [RENDER]
    )
  3. Stringified objects - Use
    JSON.stringify()
    for easy copying from browser console
  4. Remove when done - Delete diagnostic logs after debugging is complete
  1. 明确用途 - 这条日志要传达什么信息?
  2. 单一可过滤标识符 -
    [大写形式]
    前缀(例如:
    [THUMB_STRIP]
    [RENDER]
  3. 序列化对象 - 使用
    JSON.stringify()
    以便于从浏览器控制台复制
  4. 调试完成后移除 - 调试结束后删除诊断日志

Examples

示例

typescript
// ✅ Good
console.log('[THUMB_STRIP] Starting animation', JSON.stringify({ 
  loadingCount: 3,
  totalSlots: 10 
}));

// ❌ Bad - no identifier, object not stringified
console.log('Starting animation', { loadingCount: 3 });
typescript
// ✅ 规范示例
console.log('[THUMB_STRIP] Starting animation', JSON.stringify({ 
  loadingCount: 3,
  totalSlots: 10 
}));

// ❌ 不规范示例 - 无标识符,对象未序列化
console.log('Starting animation', { loadingCount: 3 });