布莱普·洛格
布莱普 是一个独立的应用程序和现代网络框架的 TypeScript 日志 . 它给你结构化的日志,框架适配器,客户端对服务器日志摄取,以及可选的连接器,而不将根的README变成完整的手册.
要点
- 在独立的应用程序中或与框架适配器一起使用.
- 使用
createStructuredLog。 。 。 . - 在日志到达输出或下游汇之前修改共同的秘密.
- 从浏览器和博览会的应用程序进入您的后端流的浏览日志 .
- 将日志转发给可选的连接器,如"新遗物","后霍格","更好的堆栈","哨兵","Databuddy",命名为"HTTP端点","OTLP"等目标.
- 为 Bun- first 设置所建,支持支持的节点运行时间 .
- 完整 TypeScript 支持整个主包和子路径导出.
安装
bun add @blyp/core
npm install @blyp/core | pnpm add @blyp/core | yarn add @blyp/core
如果您使用 Expo 日志, 请同时安装 expo-network。 。 。 .
npx expo install expo-network
快开始
import { logger } from '@blyp/core';
logger.info('Server started', { port: 3000 });
logger.success('Connected to database');
logger.error('Payment failed', { orderId: 'ord_123' });
结构化日志
import { createStructuredLog } from '@blyp/core';
const log = createStructuredLog('checkout', {
service: 'web-api',
level: 'info',
timestamp: new Date().toISOString(),
});
log.set({
user: { id: 1, plan: 'pro' },
cart: { items: 3, total: 9999 },
});
log.info('checkout started');
log.emit({ status: 200 });
内部框架处理器, createStructuredLog(...) 自动绑定在活动请求日志中 。 最终结构化记录在调用时被写入 .emit()。 。 。 .
框架实例
Blyp支持Elysia,Hono,快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活快活活快活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活.
import { Elysia } from 'elysia';
import { createLogger } from '@blyp/core/elysia';
const app = new Elysia()
.use(createLogger({ level: 'info', autoLogging: true }))
.get('/', () => 'Hello World')
.listen(3000);
见 框架集成文件 用于完整的适配器矩阵和特定框架实例.
农场.js
// farm.config.ts
import { defineConfig } from '@farm.js/core';
import { blypPlugin } from '@blyp/core/farmjs';
export default defineConfig({
plugins: [blypPlugin()],
});
// src/app/api/products/route.ts
import { logger } from '@blyp/core/farmjs';
export async function GET() {
logger.info('loaded products');
return Response.json({ ok: true });
}
该插件会自动记录请求,出错,选定的Farm生命周期事件,浏览器导航和性能遥测,浏览器出错等. 它目前支持Farm的节点和Bun服务器运行时间.
更好的认证
更好的Auth可以作为真正的Better Auth插件被附加,然后被Blip框架适配器再用来请求浓缩.
import { betterAuth } from 'better-auth';
import { blyp } from '@blyp/core/better-auth';
export const auth = betterAuth({
plugins: [
blyp({
clientLogging: true,
}),
],
});
import { createLogger } from '@blyp/core/nextjs';
import { auth } from './auth';
export const nextLogger = createLogger({
auth: {
betterAuth: auth,
},
});
import { createAuthClient } from 'better-auth/client';
import { blypClient } from '@blyp/core/better-auth';
export const authClient = createAuthClient({
plugins: [blypClient()],
});
const logger = authClient.blyp.createLogger();
logger.info('mounted');
办事员
办事员通过布莱普共享的服务器认证配置而不是插件进行集成. Blyp 用 @clerk/backend,使每个服务器日志记录上的认证状态正常化,并在客户端登录者将浏览器日志身份发布到 Blip 端点时从服务器上获取 /blyp/log。 。 。 .
import { clerk, createClerkClientLogger } from '@blyp/core/clerk';
import { createLogger } from '@blyp/core/nextjs';
export const nextLogger = createLogger({
auth: {
clerk: clerk({
secretKey: process.env.CLERK_SECRET_KEY!,
publishableKey: process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY!,
jwtKey: process.env.CLERK_JWT_KEY,
authorizedParties: ['https://app.example.com'],
}),
},
clientLogging: {
path: '/blyp/log',
},
});
export const clientLogger = createClerkClientLogger({
endpoint: '/blyp/log',
});
见 全员集成文件 用于 Next.js, Express, React Router, 以及机器认证的示例.
更多特性
- 自动编辑 对于共同的秘密,信头,和风俗模式.
- 客户和博览会记录 用于浏览器和通过后端发送日志的移动应用程序.
- AI 追踪 对于Vercel AI SDK,更好的代理, 夏娃探员, (中文(简体) ), 云雾剂事件,OpenAI,Anthropic,以及相容的运输.
- 数据库记录 当文件持久性不适合时.
- 连接器转发 新遗迹, (中文(简体) ), 邮箱, (中文(简体) ), 数据掩体, (中文(简体) ), 更好的堆叠, (中文(简体) ), 哨兵, (中文(简体) ), HTTP 密码,以及 OTLP 输油管。 。 。 .
文档
- 完整文档
- 框架整合
- 客户和博览会记录
- AI 追踪
- 数据库记录
- 后连接器
- 数据块连接器
- 更好的堆栈连接器
- 哨兵连接器
- HTTP 连接器
- 新的遗迹日志、遥测、浏览器/移动监控和账户 API
- OTLP 连接器
- 稳定政策
- 安全政策
- 捐款
- 测试文件
发展
bun install
bun run test
bun run build
bun run type-check
许可证
麻省理工学院
无存储摄入量
使用 destination: 'none' 来通过启用的连接器或OTLP转发日志,而无需本地日志文件、数据库存储或磁盘队列。 需要至少一个已配置的连接器,摄入的客户端日志必须选择一个已准备好的目标. 见 配置和客户端示例。 。 。 .
操作连接器可靠性
见 霍格后/哨兵合同, (中文(简体) ), 公布的一揽子调查,以及 CarsXE 迁移实例 用于结构化错误,核实身份,最后的负载隐私,有界限的冲洗和无持久性操作. 运行 npm run test:packed-connectors 在孤立的Node CommunityJS/ESM应用程序中验证装有真实SDK的打包包.
S3 存储
设定 destination: 's3' 在 AWS S3 、 Cloudflare R2 或 MinIO 中存储压缩日志批次,并在 Studio 中浏览,并明确允许阅读。 内存缓冲是默认的;持久的SQLite spolling是可选的. 见 S3 存储和工作室 用于配置、权限、恢复和提供者验证状态.