Skill站外收录 @skilllib/skill-2117939930272414964
logger-messages
生成简洁明了、面向用户的活动日志消息,统一采用主动语态描述操作行为,避免被动式表达,确保消息直观易懂且符合 WordPress 各类场景的上下文需求,同时保障日志标识符全局唯一。
效率工具 AI 技能
Skills.MD
# Logger Message Writing Guidelines
Guidelines for writing clear, user-friendly messages for Simple History event logs.
## When to Use This Skill
**Trigger scenarios:**
- Writing new logger messages
- Updating existing logger messages
- Creating or modifying logger classes in `loggers/` directory
- Reviewing log message clarity and tone
- Adding new events to the activity log
## Supporting Files
For comprehensive guidance:
- **[examples.md](examples.md)**: Extensive examples across all WordPress contexts (plugins, posts, users, menus, system events)
- **[integration.md](integration.md)**: Complete logger class implementation examples and best practices
## Core Principle: Active Voice
Write messages in **active tone** as if someone is telling you what happened in the present or recent past.
**Think of it as**: "I just did this action" or "Someone just performed this task"
## The Golden Rule
✅ **Do**: Use active voice - what action was performed
❌ **Don't**: Use passive voice - what was done to something
## Quick Examples
```
✅ DO ❌ DON'T
─────────────────────────────────────────────
Activated plugin Plugin was activated
Created menu Menu has been created
Updated settings Settings were updated
Detected modifications Modifications were detected
Changed password Password was changed
Published post Post has been published
```
See [examples.md](examples.md) for comprehensive examples across all contexts.
## Key Characteristics
### 1. User-Friendly Language
Write for regular users, not developers.
✅ "Updated site settings"
❌ "Modified wp_options table"
### 2. Concise and Clear
Remove filler words. Be direct.
✅ "Published post"
❌ "Successfully published the post to the website"
### 3. Specific When Needed
Include relevant context without overwhelming.
✅ "Changed site language to Spanish"
❌ "Updated something"
## Message Structure in Code
### In Logger Classes
```php
class SimpleHistoryPluginLogger extends SimpleLogger {
public function getInfo() {
return [
'messages' => [
// ✅ All active voice
'plugin_activated' => __( 'Activated plugin', 'simple-history' ),
'plugin_deactivated' => __( 'Deactivated plugin', 'simple-history' ),
'plugin_installed' => __( 'Installed plugin', 'simple-history' ),
],
];
}
}
```
### With Context Variables
```php
// ✅ Good - Clear placeholders
'post_updated' => __( 'Updated post "{post_title}"', 'simple-history' )
// ✅ Good - Multiple variables
'role_changed' => __( 'Changed role from {old_role} to {new_role}', 'simple-history' )
```
## Message Key Uniqueness
Message keys must be globally unique across all loggers, not just within a single logger.
### Why Uniqueness Matters
Message keys are used as message identifiers in syslog RFC 5424 logging, where unique MSGID values are required for proper log parsing and filtering. Duplicate keys would cause conflicts in external logging systems.
### Best Practices for Unique Keys
```php
// ✅ Good - Use descriptive prefixes that indicate the logger context
'plugin_activated' // Plugin_Logger
'theme_switched' // Theme_Logger
'user_logged_in' // User_Logger
'privacy_data_exported' // Privacy_Logger
'crontrol_event_added' // Plugin_WP_Crontrol_Logger
// ❌ Bad - Generic keys that could conflict
'activated' // Too generic
'updated' // Could exist in multiple loggers
'deleted' // Ambiguous
```
### Verification
Before adding new message keys, verify they don't already exist in other loggers:
```bash
# Search for existing key usage
grep -r "'your_proposed_key'" loggers/
```
## Common Verbs to Use
- **Creation**: Created, Added, Generated
- **Modification**: Updated, Changed, Modified, Edited
- **Deletion**: Deleted, Removed, Trashed
- **Activation**: Activated, Deactivated, Enabled, Disabled
- **Publication**: Published, Unpublished, Scheduled
- **Detection**: Detected, Found, Discovered
## Verbs to Avoid
Never use passive constructions:
- ❌ "was [verb]" → "was activated"
- ❌ "has been [verb]" → "has been created"
- ❌ "got [verb]" → "got updated"
## Testing Your Messages
Ask yourself:
1. **Is it active?** Does it sound like someone telling you what they did?
2. **Is it clear?** Would a non-technical user understand?
3. **Is it concise?** Can you remove words without losing meaning?
4. **Is it specific?** Does it tell you exactly what happened?
## Summary
**Remember**: Write as if you're telling someone what you just did, not what happened to something.
**Pattern**: [I/Someone] + [Action verb] + [Object] + [Optional context]
**Always**: Active voice, user-friendly, concise, specific
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「logger-messages」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次