🖥️
后端开发

编码器 Rust 日志记录

@coder-rust-logging

<skill_overview> 为 Rust 服务实现结构化日志记录和跟踪 添加日志或诊断 围绕操作创建跨度 配置跟踪订阅者 确保不记录敏感数据 跟踪 GitHub </skill_overview> <events_and_spans> 对有持续时间的操作使用跨度 将事件用于时间点事实 将结构化字段附加到跨度和事件 </events_and_spans> <structed_logging> 优先选择结构化字段而不是字符串插值 使用一致的字段名称和类型跟踪::info!(user_id, action = "登录", "用户操作"); </structed_logging> 使用 #[instrument] 自动创建跨度 使用 #[instrument(skip(secret))] 跳过敏感字段 #[tracing::instrument(skip(password))] fnauthenticate(username: &str, password: &str) { /* ... */ } <subscriber_setup> 在 main 中尽早初始化订阅者 对日志级别使用基于环境的过滤 保持默认级别对于生产来说合理Tracing_subscriber::fmt().with_env_filter("info").init(); </subscriber_setup> <sensitive_data> <never_log> 密码和令牌 API 密钥和秘密 PII(不需要时) </never_log> </sensitive_data> <anti_patterns> 避免 println!用于生产日志记录避免信息日志中的高基数字段</anti_patterns>

包含技能

1 个
🖥️
编码器 Rust 日志记录
@ozerohax/assistagents/coder-rust-logging

<skill_overview> 为 Rust 服务实现结构化日志记录和跟踪 添加日志或诊断 围绕操作创建跨度 配置跟踪订阅者 确保不记录敏感数据 跟踪 GitHub </skill_overview> <events_and_spans> 对有持续时间的操作使用跨度 将事件用于时间点事实 将结构化字段附加到跨度和事件 </events_and_spans> <structed_logging> 优先选择结构化字段而不是字符串插值 使用一致的字段名称和类型跟踪::info!(user_id, action = "登录", "用户操作"); </structed_logging> 使用 #[instrument] 自动创建跨度 使用 #[instrument(skip(secret))] 跳过敏感字段 #[tracing::instrument(skip(password))] fnauthenticate(username: &str, password: &str) { /* ... */ } <subscriber_setup> 在 main 中尽早初始化订阅者 对日志级别使用基于环境的过滤 保持默认级别对于生产来说合理Tracing_subscriber::fmt().with_env_filter("info").init(); </subscriber_setup> <sensitive_data> <never_log> 密码和令牌 API 密钥和秘密 PII(不需要时) </never_log> </sensitive_data> <anti_patterns> 避免 println!用于生产日志记录避免信息日志中的高基数字段</anti_patterns>

🚀 如何安装技能包 请下载安装 AiOffice 客户端,
如果已下载AiOffice,
请在 AiOffice 的技能广场页面进行一键安装。