展示HN:Timberlogs – TypeScript 的即插即用结构化日志记录
嗨,HN!我创建了Timberlogs,因为我厌倦了在生产环境中使用console.log,并且现有的日志解决方案需要过多的设置。
Timberlogs是一个适用于TypeScript的即插即用结构化日志库:
```bash
npm install timberlogs-client
```
```typescript
import { createTimberlogs } from "timberlogs-client";
const timber = createTimberlogs({
source: "my-app",
environment: "production",
apiKey: process.env.TIMBER_API_KEY,
});
timber.info("用户已登录", { userId: "123" });
timber.error("支付失败", error);
```
功能特点:
- 自动批处理和重试
- 自动屏蔽敏感数据(密码、令牌)
- 全文搜索所有日志
- 实时仪表盘
- 流程追踪以链接相关日志
目前该项目处于测试阶段,免费使用。非常希望得到HN社区的反馈。
网站: [https://timberlogs.dev](https://timberlogs.dev)
文档: [https://docs.timberlogs.dev](https://docs.timberlogs.dev)
npm: [https://npmjs.com/package/timberlogs-client](https://npmjs.com/package/timberlogs-client)
GitHub: [https://github.com/enaboapps/timberlogs-typescript-sdk](https://github.com/enaboapps/timberlogs-typescript-sdk)
查看原文
Hi HN! I built Timberlogs because I was tired of console.log in production and existing logging solutions requiring too much setup.<p>Timberlogs is a drop-in structured logging library for TypeScript:<p><pre><code> npm install timberlogs-client
import { createTimberlogs } from "timberlogs-client";
const timber = createTimberlogs({
source: "my-app",
environment: "production",
apiKey: process.env.TIMBER_API_KEY,
});
timber.info("User signed in", { userId: "123" });
timber.error("Payment failed", error);
</code></pre>
Features:
- Auto-batching with retries
- Automatic redaction of sensitive data (passwords, tokens)
- Full-text search across all your logs
- Real-time dashboard
- Flow tracking to link related logs<p>It's currently in beta and free to use. Would love feedback from the HN community.<p>Site: <a href="https://timberlogs.dev" rel="nofollow">https://timberlogs.dev</a>
Docs: <a href="https://docs.timberlogs.dev" rel="nofollow">https://docs.timberlogs.dev</a>
npm: <a href="https://npmjs.com/package/timberlogs-client" rel="nofollow">https://npmjs.com/package/timberlogs-client</a>
GitHub: <a href="https://github.com/enaboapps/timberlogs-typescript-sdk" rel="nofollow">https://github.com/enaboapps/timberlogs-typescript-sdk</a>