重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
logging-best-practices by secondsky/claude-skills
npx skills add https://github.com/secondsky/claude-skills --skill logging-best-practices实现安全、结构化的日志记录,包含适当的级别和上下文。
| 级别 | 用途 | 生产环境 |
|---|---|---|
| DEBUG | 详细调试信息 | 关闭 |
| INFO | 正常操作信息 | 开启 |
| WARN | 潜在问题 | 开启 |
| ERROR | 可恢复的错误 | 开启 |
| FATAL | 严重故障 | 开启 |
const winston = require('winston');
const logger = winston.createLogger({
level: process.env.LOG_LEVEL || 'info',
format: winston.format.combine(
winston.format.timestamp(),
winston.format.json()
),
defaultMeta: { service: 'api-service' },
transports: [
new winston.transports.Console(),
new winston.transports.File({ filename: 'error.log', level: 'error' })
]
});
// 使用示例
logger.info('User logged in', { userId: '123', ip: '192.168.1.1' });
logger.error('Payment failed', { error: err.message, orderId: '456' });
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
const { AsyncLocalStorage } = require('async_hooks');
const storage = new AsyncLocalStorage();
app.use((req, res, next) => {
const context = {
requestId: req.headers['x-request-id'] || uuid(),
userId: req.user?.id
};
storage.run(context, next);
});
function log(level, message, meta = {}) {
const context = storage.getStore() || {};
logger.log(level, message, { ...context, ...meta });
}
const sensitiveFields = ['password', 'ssn', 'creditCard', 'token'];
function sanitize(obj) {
const sanitized = { ...obj };
for (const field of sensitiveFields) {
if (sanitized[field]) sanitized[field] = '[REDACTED]';
}
if (sanitized.email) {
sanitized.email = sanitized.email.replace(/(.{2}).*@/, '$1***@');
}
return sanitized;
}
每周安装次数
64
代码仓库
GitHub 星标数
90
首次出现时间
2026年1月25日
安全审计
已安装于
claude-code56
gemini-cli52
cursor52
codex51
opencode50
github-copilot48
Implement secure, structured logging with proper levels and context.
| Level | Use For | Production |
|---|---|---|
| DEBUG | Detailed debugging | Off |
| INFO | Normal operations | On |
| WARN | Potential issues | On |
| ERROR | Errors with recovery | On |
| FATAL | Critical failures | On |
const winston = require('winston');
const logger = winston.createLogger({
level: process.env.LOG_LEVEL || 'info',
format: winston.format.combine(
winston.format.timestamp(),
winston.format.json()
),
defaultMeta: { service: 'api-service' },
transports: [
new winston.transports.Console(),
new winston.transports.File({ filename: 'error.log', level: 'error' })
]
});
// Usage
logger.info('User logged in', { userId: '123', ip: '192.168.1.1' });
logger.error('Payment failed', { error: err.message, orderId: '456' });
const { AsyncLocalStorage } = require('async_hooks');
const storage = new AsyncLocalStorage();
app.use((req, res, next) => {
const context = {
requestId: req.headers['x-request-id'] || uuid(),
userId: req.user?.id
};
storage.run(context, next);
});
function log(level, message, meta = {}) {
const context = storage.getStore() || {};
logger.log(level, message, { ...context, ...meta });
}
const sensitiveFields = ['password', 'ssn', 'creditCard', 'token'];
function sanitize(obj) {
const sanitized = { ...obj };
for (const field of sensitiveFields) {
if (sanitized[field]) sanitized[field] = '[REDACTED]';
}
if (sanitized.email) {
sanitized.email = sanitized.email.replace(/(.{2}).*@/, '$1***@');
}
return sanitized;
}
See references/advanced-logging.md for:
Weekly Installs
64
Repository
GitHub Stars
90
First Seen
Jan 25, 2026
Security Audits
Gen Agent Trust HubFailSocketPassSnykPass
Installed on
claude-code56
gemini-cli52
cursor52
codex51
opencode50
github-copilot48
Azure Data Explorer (Kusto) 查询技能:KQL数据分析、日志遥测与时间序列处理
152,400 周安装
小红书自动化发布与互动工具 - RedBookSkills 实现图文视频一键发布、内容检索与数据管理
295 周安装
nano-banana AI图像生成命令行工具:Gemini 3.1 Flash/Pro模型,支持透明背景与风格迁移
301 周安装
Google Maps 迁移到 Mapbox GL JS 完整指南:API 对照、代码转换与最佳实践
300 周安装
PARA第二大脑技能:AI助手帮你用PARA方法组织知识库和数字笔记
295 周安装
Sentry PHP SDK 安装配置指南:PHP/Laravel/Symfony 错误监控与性能追踪
305 周安装
UI/UX原型提示词生成器 - 为AI和开发者创建结构化设计规范
299 周安装