logging-best-practices by aj-geddes/useful-ai-prompts
npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill logging-best-practices关于在应用程序中实现结构化、安全且高性能日志记录的全面指南。涵盖日志级别、结构化日志格式、上下文信息、个人身份信息保护以及集中式日志系统。
最小工作示例:
// logger.ts
enum LogLevel {
DEBUG = 0, // 用于调试的详细信息
INFO = 1, // 常规信息性消息
WARN = 2, // 警告消息,可能存在危害
ERROR = 3, // 错误消息,应用程序可以继续运行
FATAL = 4, // 严重错误,应用程序必须停止
}
class Logger {
constructor(private minLevel: LogLevel = LogLevel.INFO) {}
debug(message: string, context?: object) {
if (this.minLevel <= LogLevel.DEBUG) {
this.log(LogLevel.DEBUG, message, context);
}
}
info(message: string, context?: object) {
if (this.minLevel <= LogLevel.INFO) {
this.log(LogLevel.INFO, message, context);
}
}
warn(message: string, context?: object) {
// ... (完整实现请参阅参考指南)
目录下的详细实现:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
references/| 指南 | 内容 |
|---|---|
| 日志级别 | 日志级别 |
| 结构化日志记录 (JSON) | 结构化日志记录 (JSON) |
| 上下文日志记录 | 上下文日志记录 |
| 个人身份信息与敏感数据处理 | 个人身份信息与敏感数据处理 |
| 性能日志记录 | 性能日志记录 |
| 集中式日志记录 | 集中式日志记录 |
| 分布式追踪 | 分布式追踪 |
| 日志采样 (高流量服务) | 日志采样 (高流量服务) |
每周安装次数
114
代码仓库
GitHub 星标数
116
首次出现
2026年1月21日
安全审计
安装于
opencode93
gemini-cli89
claude-code89
codex87
cursor86
github-copilot74
Comprehensive guide to implementing structured, secure, and performant logging across applications. Covers log levels, structured logging formats, contextual information, PII protection, and centralized logging systems.
Minimal working example:
// logger.ts
enum LogLevel {
DEBUG = 0, // Detailed information for debugging
INFO = 1, // General informational messages
WARN = 2, // Warning messages, potentially harmful
ERROR = 3, // Error messages, application can continue
FATAL = 4, // Critical errors, application must stop
}
class Logger {
constructor(private minLevel: LogLevel = LogLevel.INFO) {}
debug(message: string, context?: object) {
if (this.minLevel <= LogLevel.DEBUG) {
this.log(LogLevel.DEBUG, message, context);
}
}
info(message: string, context?: object) {
if (this.minLevel <= LogLevel.INFO) {
this.log(LogLevel.INFO, message, context);
}
}
warn(message: string, context?: object) {
// ... (see reference guides for full implementation)
Detailed implementations in the references/ directory:
| Guide | Contents |
|---|---|
| Log Levels | Log Levels |
| Structured Logging (JSON) | Structured Logging (JSON) |
| Contextual Logging | Contextual Logging |
| PII and Sensitive Data Handling | PII and Sensitive Data Handling |
| Performance Logging | Performance Logging |
| Centralized Logging | Centralized Logging |
| Distributed Tracing |
Weekly Installs
114
Repository
GitHub Stars
116
First Seen
Jan 21, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode93
gemini-cli89
claude-code89
codex87
cursor86
github-copilot74
Azure Data Explorer (Kusto) 查询技能:KQL数据分析、日志遥测与时间序列处理
125,100 周安装
| Distributed Tracing |
| Log Sampling (High-Volume Services) | Log Sampling (High-Volume Services) |