repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | --- |
| #2 | description: |
| #3 | globs: |
| #4 | alwaysApply: false |
| #5 | --- |
| #6 | # Custom Logger System Guide |
| #7 | |
| #8 | This project uses a custom logging system located in [scripts/utils/logger.ts](mdc:scripts/utils/logger.ts) for consistent, structured output across all scripts. |
| #9 | |
| #10 | ## 🚨 Critical Rule |
| #11 | **NEVER use `console.log`, `console.warn`, `console.error` directly in any scripts.** Always use the custom Logger. |
| #12 | |
| #13 | ## 📝 Logger Usage Patterns |
| #14 | |
| #15 | ### Basic Import |
| #16 | ```typescript |
| #17 | import { Logger } from '../utils/logger'; |
| #18 | // OR import specific functions |
| #19 | import { info, warn, error, success, start } from '../utils/logger'; |
| #20 | ``` |
| #21 | |
| #22 | ### Common Logging Methods |
| #23 | |
| #24 | #### Information and Status |
| #25 | ```typescript |
| #26 | Logger.info('处理文件', '文件名或详情'); |
| #27 | Logger.success('操作完成', '目标', '详细信息'); |
| #28 | Logger.warn('警告信息', '原因或详情'); |
| #29 | Logger.error('错误信息', '错误对象或详情'); |
| #30 | ``` |
| #31 | |
| #32 | #### Process Flow |
| #33 | ```typescript |
| #34 | Logger.start('开始操作', '目标', '详细信息'); |
| #35 | Logger.split('分隔线标题', '='); // 创建分隔线 |
| #36 | ``` |
| #37 | |
| #38 | #### File Operations |
| #39 | ```typescript |
| #40 | Logger.file('read', 'path/to/file.json', 'success'); |
| #41 | Logger.file('write', 'path/to/file.json', 'start'); |
| #42 | Logger.file('delete', 'path/to/file.json', 'error'); |
| #43 | ``` |
| #44 | |
| #45 | #### Translation Process |
| #46 | ```typescript |
| #47 | Logger.translate(agentId, '源语言', '目标语言', 'start'); |
| #48 | Logger.translate(agentId, '源语言', '目标语言', 'success'); |
| #49 | Logger.translate(agentId, '源语言', '目标语言', 'skip'); |
| #50 | Logger.translate(agentId, '源语言', '目标语言', 'error'); |
| #51 | ``` |
| #52 | |
| #53 | #### Progress and Statistics |
| #54 | ```typescript |
| #55 | Logger.progress(current, total, '操作描述'); |
| #56 | Logger.stats({ |
| #57 | '总文件数': totalCount, |
| #58 | '成功数量': successCount, |
| #59 | '失败数量': failureCount |
| #60 | }); |
| #61 | ``` |
| #62 | |
| #63 | ## 🎨 Logger Features |
| #64 | |
| #65 | ### Colored Output |
| #66 | - Uses `consola` with colored icons and formatting |
| #67 | - Different colors for different log levels |
| #68 | - Consistent visual hierarchy |
| #69 | |
| #70 | ### Structured Information |
| #71 | - Progress bars for long operations |
| #72 | - Statistical summaries |
| #73 | - File operation tracking |
| #74 | - Translation workflow logging |
| #75 | |
| #76 | ### Debugging Support |
| #77 | ```typescript |
| #78 | Logger.debug('调试信息', debugData); |
| #79 | ``` |
| #80 | |
| #81 | ## 📋 Migration from console.* |
| #82 | |
| #83 | ### Old Pattern ❌ |
| #84 | ```typescript |
| #85 | console.log('Processing file:', fileName); |
| #86 | console.warn('File not found:', filePath); |
| #87 | console.error('Error occurred:', error); |
| #88 | ``` |
| #89 | |
| #90 | ### New Pattern ✅ |
| #91 | ```typescript |
| #92 | Logger.info('处理文件', fileName); |
| #93 | Logger.warn('文件未找到', filePath); |
| #94 | Logger.error('发生错误', error); |
| #95 | ``` |
| #96 | |
| #97 | ## 🔧 Command Line Tools |
| #98 | |
| #99 | Commands like [scripts/commands/validate-language.ts](mdc:scripts/commands/validate-language.ts) demonstrate proper Logger usage: |
| #100 | - Use `Logger.split()` for section headers |
| #101 | - Use appropriate log levels for different message types |
| #102 | - Provide structured output with `Logger.stats()` |
| #103 | - Use `Logger.file()` for file operations |
| #104 | |
| #105 | |
| #106 | |
| #107 |