@blyp/core 0.1.21 → 0.1.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -522
- package/STABILITY.md +56 -0
- package/dist/ai/anthropic/index.d.ts +3 -0
- package/dist/ai/anthropic/normalize.d.ts +9 -0
- package/dist/ai/anthropic/stream.d.ts +3 -0
- package/dist/ai/anthropic/wrap.d.ts +13 -0
- package/dist/ai/anthropic.js +701 -0
- package/dist/ai/anthropic.mjs +701 -0
- package/dist/ai/better-agent/index.d.ts +3 -0
- package/dist/ai/better-agent/normalize.d.ts +18 -0
- package/dist/ai/better-agent/plugin.d.ts +3 -0
- package/dist/ai/better-agent/tracker.d.ts +35 -0
- package/dist/ai/better-agent.js +701 -0
- package/dist/ai/better-agent.mjs +701 -0
- package/dist/ai/fetch.js +701 -0
- package/dist/ai/fetch.mjs +701 -0
- package/dist/ai/openai/index.d.ts +3 -0
- package/dist/ai/openai/normalize.d.ts +10 -0
- package/dist/ai/openai/stream.d.ts +3 -0
- package/dist/ai/openai/wrap.d.ts +24 -0
- package/dist/ai/openai.js +701 -0
- package/dist/ai/openai.mjs +701 -0
- package/dist/ai/shared/fetch.d.ts +5 -0
- package/dist/ai/shared/index.d.ts +2 -0
- package/dist/ai/shared/normalize.d.ts +17 -0
- package/dist/ai/shared/redaction.d.ts +6 -0
- package/dist/ai/shared/stream.d.ts +7 -0
- package/dist/ai/shared/trace.d.ts +119 -0
- package/dist/ai/shared/types.d.ts +171 -0
- package/dist/ai/shared.js +701 -0
- package/dist/ai/shared.mjs +701 -0
- package/dist/ai/vercel/index.d.ts +3 -0
- package/dist/ai/vercel/middleware.d.ts +3 -0
- package/dist/ai/vercel/model.d.ts +3 -0
- package/dist/ai/vercel.js +701 -0
- package/dist/ai/vercel.mjs +701 -0
- package/dist/astro.js +618 -4519
- package/dist/astro.mjs +618 -4491
- package/dist/client.js +1 -1139
- package/dist/client.mjs +1 -1132
- package/dist/connectors/betterstack.js +9 -1532
- package/dist/connectors/betterstack.mjs +9 -1507
- package/dist/connectors/databuddy.js +9 -1456
- package/dist/connectors/databuddy.mjs +9 -1451
- package/dist/connectors/delivery/backoff.d.ts +2 -0
- package/dist/connectors/delivery/manager.d.ts +44 -0
- package/dist/connectors/delivery/queue-path.d.ts +1 -0
- package/dist/connectors/delivery/sqlite-adapter-bun.d.ts +1 -0
- package/dist/connectors/delivery/sqlite-adapter-node.d.ts +1 -0
- package/dist/connectors/delivery/sqlite-client.d.ts +37 -0
- package/dist/connectors/delivery/sqlite-worker.d.ts +1 -0
- package/dist/connectors/delivery/studio-queue.d.ts +12 -0
- package/dist/connectors/delivery/types.d.ts +98 -0
- package/dist/connectors/otlp/index.d.ts +1 -0
- package/dist/connectors/otlp.js +9 -1371
- package/dist/connectors/otlp.mjs +9 -1368
- package/dist/connectors/posthog/properties.d.ts +4 -0
- package/dist/connectors/posthog/sender.d.ts +0 -1
- package/dist/connectors/posthog.js +10 -1527
- package/dist/connectors/posthog.mjs +10 -1522
- package/dist/connectors/sentry.js +9 -1380
- package/dist/connectors/sentry.mjs +9 -1357
- package/dist/core/config.d.ts +7 -2
- package/dist/core/log-record.d.ts +5 -4
- package/dist/core/logger.d.ts +2 -0
- package/dist/core/optional-module.d.ts +1 -0
- package/dist/core/pino-pretty-loader.d.ts +4 -0
- package/dist/database.js +1 -24
- package/dist/database.mjs +1 -21
- package/dist/elysia.js +613 -4517
- package/dist/elysia.mjs +615 -4491
- package/dist/expo.js +1 -726
- package/dist/expo.mjs +1 -724
- package/dist/express.js +613 -4507
- package/dist/express.mjs +615 -4480
- package/dist/fastify.js +615 -4526
- package/dist/fastify.mjs +617 -4499
- package/dist/frameworks/elysia/index.d.ts +1 -1
- package/dist/frameworks/elysia/logger.d.ts +2 -35
- package/dist/frameworks/nestjs/helpers.d.ts +2 -0
- package/dist/frameworks/shared/http.d.ts +3 -2
- package/dist/frameworks/shared/index.d.ts +2 -1
- package/dist/frameworks/shared/logger.d.ts +2 -0
- package/dist/frameworks/shared/request-context.d.ts +2 -0
- package/dist/frameworks/shared/trace.d.ts +6 -0
- package/dist/hono.js +616 -4496
- package/dist/hono.mjs +618 -4470
- package/dist/index.d.ts +49 -19
- package/dist/index.js +615 -7557
- package/dist/index.mjs +618 -7465
- package/dist/nestjs.js +626 -4999
- package/dist/nestjs.mjs +621 -4966
- package/dist/nextjs.js +618 -4525
- package/dist/nextjs.mjs +620 -4499
- package/dist/nitro.js +617 -4642
- package/dist/nitro.mjs +619 -4616
- package/dist/nuxt.js +617 -4649
- package/dist/nuxt.mjs +619 -4623
- package/dist/react-router.js +616 -4559
- package/dist/react-router.mjs +618 -4533
- package/dist/shared/redaction.d.ts +17 -0
- package/dist/standalone.js +606 -3628
- package/dist/standalone.mjs +610 -3603
- package/dist/sveltekit.js +617 -4523
- package/dist/sveltekit.mjs +619 -4497
- package/dist/tanstack-start.js +616 -4522
- package/dist/tanstack-start.mjs +618 -4496
- package/dist/types/core/config.d.ts +57 -0
- package/dist/types/core/logger.d.ts +3 -0
- package/dist/types/core/structured-log.d.ts +2 -0
- package/dist/types/database.d.ts +1 -0
- package/dist/types/frameworks/astro.d.ts +1 -0
- package/dist/types/frameworks/client.d.ts +2 -0
- package/dist/types/frameworks/elysia.d.ts +2 -0
- package/dist/types/frameworks/express.d.ts +1 -0
- package/dist/types/frameworks/fastify.d.ts +1 -0
- package/dist/types/frameworks/hono.d.ts +1 -0
- package/dist/types/frameworks/http.d.ts +1 -0
- package/dist/types/frameworks/nestjs.d.ts +2 -0
- package/dist/types/frameworks/nextjs.d.ts +1 -0
- package/dist/types/frameworks/nitro.d.ts +1 -0
- package/dist/types/frameworks/react-router.d.ts +2 -0
- package/dist/types/frameworks/request-context.d.ts +1 -0
- package/dist/types/frameworks/shared.d.ts +4 -1
- package/dist/types/frameworks/standalone.d.ts +3 -2
- package/dist/types/frameworks/sveltekit.d.ts +1 -0
- package/dist/types/frameworks/tanstack-start.d.ts +9 -3
- package/dist/types/frameworks/workers.d.ts +3 -0
- package/dist/types/shared/client-log.d.ts +1 -0
- package/dist/workers.js +2 -626
- package/dist/workers.mjs +2 -623
- package/package.json +259 -173
- package/dist/astro.js.map +0 -1
- package/dist/astro.mjs.map +0 -1
- package/dist/client.js.map +0 -1
- package/dist/client.mjs.map +0 -1
- package/dist/connectors/betterstack.js.map +0 -1
- package/dist/connectors/betterstack.mjs.map +0 -1
- package/dist/connectors/databuddy.js.map +0 -1
- package/dist/connectors/databuddy.mjs.map +0 -1
- package/dist/connectors/otlp.js.map +0 -1
- package/dist/connectors/otlp.mjs.map +0 -1
- package/dist/connectors/posthog.js.map +0 -1
- package/dist/connectors/posthog.mjs.map +0 -1
- package/dist/connectors/sentry.js.map +0 -1
- package/dist/connectors/sentry.mjs.map +0 -1
- package/dist/database.js.map +0 -1
- package/dist/database.mjs.map +0 -1
- package/dist/elysia.js.map +0 -1
- package/dist/elysia.mjs.map +0 -1
- package/dist/expo.js.map +0 -1
- package/dist/expo.mjs.map +0 -1
- package/dist/express.js.map +0 -1
- package/dist/express.mjs.map +0 -1
- package/dist/fastify.js.map +0 -1
- package/dist/fastify.mjs.map +0 -1
- package/dist/hono.js.map +0 -1
- package/dist/hono.mjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/nestjs.js.map +0 -1
- package/dist/nestjs.mjs.map +0 -1
- package/dist/nextjs.js.map +0 -1
- package/dist/nextjs.mjs.map +0 -1
- package/dist/nitro.js.map +0 -1
- package/dist/nitro.mjs.map +0 -1
- package/dist/nuxt.js.map +0 -1
- package/dist/nuxt.mjs.map +0 -1
- package/dist/react-router.js.map +0 -1
- package/dist/react-router.mjs.map +0 -1
- package/dist/standalone.js.map +0 -1
- package/dist/standalone.mjs.map +0 -1
- package/dist/sveltekit.js.map +0 -1
- package/dist/sveltekit.mjs.map +0 -1
- package/dist/tanstack-start.js.map +0 -1
- package/dist/tanstack-start.mjs.map +0 -1
- package/dist/workers.js.map +0 -1
- package/dist/workers.mjs.map +0 -1
- package/exports/client.js +0 -3
- package/exports/client.mjs +0 -3
- package/exports/connectors/betterstack.js +0 -1
- package/exports/connectors/betterstack.mjs +0 -1
- package/exports/connectors/databuddy.js +0 -1
- package/exports/connectors/databuddy.mjs +0 -1
- package/exports/connectors/otlp.js +0 -1
- package/exports/connectors/otlp.mjs +0 -1
- package/exports/connectors/posthog.js +0 -1
- package/exports/connectors/posthog.mjs +0 -1
- package/exports/connectors/sentry.js +0 -1
- package/exports/connectors/sentry.mjs +0 -1
- package/exports/database.js +0 -1
- package/exports/database.mjs +0 -1
- package/exports/expo.js +0 -1
- package/exports/expo.mjs +0 -1
- package/exports/frameworks/astro.js +0 -1
- package/exports/frameworks/astro.mjs +0 -1
- package/exports/frameworks/elysia.js +0 -1
- package/exports/frameworks/elysia.mjs +0 -1
- package/exports/frameworks/express.js +0 -1
- package/exports/frameworks/express.mjs +0 -1
- package/exports/frameworks/fastify.js +0 -1
- package/exports/frameworks/fastify.mjs +0 -1
- package/exports/frameworks/hono.js +0 -1
- package/exports/frameworks/hono.mjs +0 -1
- package/exports/frameworks/nestjs.js +0 -1
- package/exports/frameworks/nestjs.mjs +0 -1
- package/exports/frameworks/nextjs.js +0 -1
- package/exports/frameworks/nextjs.mjs +0 -1
- package/exports/frameworks/nitro.js +0 -1
- package/exports/frameworks/nitro.mjs +0 -1
- package/exports/frameworks/nuxt.js +0 -1
- package/exports/frameworks/nuxt.mjs +0 -1
- package/exports/frameworks/react-router.js +0 -1
- package/exports/frameworks/react-router.mjs +0 -1
- package/exports/frameworks/standalone.js +0 -1
- package/exports/frameworks/standalone.mjs +0 -1
- package/exports/frameworks/sveltekit.js +0 -1
- package/exports/frameworks/sveltekit.mjs +0 -1
- package/exports/frameworks/tanstack-start.js +0 -1
- package/exports/frameworks/tanstack-start.mjs +0 -1
- package/exports/workers.js +0 -1
- package/exports/workers.mjs +0 -1
- package/types/client.d.ts +0 -34
- package/types/connectors/betterstack.d.ts +0 -1
- package/types/connectors/databuddy.d.ts +0 -1
- package/types/connectors/otlp.d.ts +0 -1
- package/types/connectors/posthog.d.ts +0 -1
- package/types/connectors/sentry.d.ts +0 -1
- package/types/database.d.ts +0 -1
- package/types/expo.d.ts +0 -17
- package/types/frameworks/astro.d.ts +0 -1
- package/types/frameworks/client.d.ts +0 -160
- package/types/frameworks/elysia.d.ts +0 -1
- package/types/frameworks/expo.d.ts +0 -50
- package/types/frameworks/express.d.ts +0 -1
- package/types/frameworks/fastify.d.ts +0 -1
- package/types/frameworks/hono.d.ts +0 -1
- package/types/frameworks/nestjs.d.ts +0 -1
- package/types/frameworks/nextjs.d.ts +0 -1
- package/types/frameworks/nitro.d.ts +0 -1
- package/types/frameworks/nuxt.d.ts +0 -1
- package/types/frameworks/react-router.d.ts +0 -1
- package/types/frameworks/standalone.d.ts +0 -1
- package/types/frameworks/sveltekit.d.ts +0 -1
- package/types/frameworks/tanstack-start.d.ts +0 -1
- package/types/frameworks/workers.d.ts +0 -115
- package/types/index.d.ts +0 -1
- package/types/workers.d.ts +0 -13
package/README.md
CHANGED
|
@@ -1,159 +1,73 @@
|
|
|
1
1
|
# Blyp Logger
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
> *The silent observer for your applications*
|
|
6
|
-
|
|
7
|
-
**Blyp** is a high-performance, runtime-adaptive logger for standalone apps and modern TypeScript web frameworks. It combines Bun-friendly runtime detection, structured NDJSON file logging, browser-to-server log ingestion, and framework-specific HTTP logging helpers.
|
|
3
|
+
**Blyp** is a TypeScript logger for standalone apps and modern web frameworks.
|
|
4
|
+
It gives you structured logging, framework adapters, client-to-server log ingestion, and optional connectors without turning the root README into a full manual.
|
|
8
5
|
|
|
9
6
|
[](https://bun.sh)
|
|
10
7
|
[](https://www.typescriptlang.org)
|
|
11
8
|
[](https://elysiajs.com)
|
|
12
9
|
|
|
13
|
-
##
|
|
14
|
-
|
|
15
|
-
- **Runtime detection** — Automatically optimizes for Bun vs Node.js
|
|
16
|
-
- **TypeScript** — Full type safety throughout
|
|
17
|
-
- **Framework integrations** — Elysia, Hono, Express, Fastify, NestJS, Next.js App Router, React Router, Astro, Nitro, Nuxt, TanStack Start, SvelteKit, Cloudflare Workers
|
|
18
|
-
- **Expo integration** — Mobile client logging for Expo apps with structured backend sync
|
|
19
|
-
- **PostHog connector** — Automatic or manual PostHog log forwarding for server, browser, and Expo flows
|
|
20
|
-
- **Databuddy connector** — Automatic or manual Databuddy log forwarding and handled-error tracking for server, browser, and Expo flows
|
|
21
|
-
- **OTLP connector** — Automatic or manual OpenTelemetry log forwarding for Grafana, Datadog, Honeycomb, and any OTLP-compatible backend
|
|
22
|
-
- **Standalone usage** — Use without any framework
|
|
23
|
-
- **Structured file logging** — NDJSON with size-based rotation and gzip archives
|
|
24
|
-
- **Database logging** — Serverless-friendly persistence with Prisma and Drizzle adapters for Postgres and MySQL
|
|
25
|
-
- **Client log sync** — Browser logs ingested into your backend stream
|
|
10
|
+
## Highlights
|
|
26
11
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
│ │ └── posthog.js # Public connector entry shims
|
|
35
|
-
│ └── frameworks/
|
|
36
|
-
│ └── elysia.js # Public framework entry shims
|
|
37
|
-
├── index.ts # Main source export bridge
|
|
38
|
-
├── src/
|
|
39
|
-
│ ├── core/ # Logger runtime and file logging internals
|
|
40
|
-
│ ├── connectors/ # Connector implementations
|
|
41
|
-
│ ├── frameworks/ # Framework implementations
|
|
42
|
-
│ ├── shared/ # Shared runtime/error utilities
|
|
43
|
-
│ └── types/
|
|
44
|
-
│ ├── framework.types.ts # Shared public contracts
|
|
45
|
-
│ ├── connectors/
|
|
46
|
-
│ │ └── posthog.ts # Connector-specific source types
|
|
47
|
-
│ └── frameworks/
|
|
48
|
-
│ └── elysia.ts # Framework-specific source types
|
|
49
|
-
├── types/
|
|
50
|
-
│ ├── index.d.ts # Public type entry shim
|
|
51
|
-
│ ├── connectors/
|
|
52
|
-
│ │ └── posthog.d.ts # Public connector type shims
|
|
53
|
-
│ └── frameworks/
|
|
54
|
-
│ └── elysia.d.ts # Public framework type shims
|
|
55
|
-
├── tests/
|
|
56
|
-
│ ├── frameworks/ # One test file per server integration
|
|
57
|
-
│ ├── helpers/ # Shared test utilities
|
|
58
|
-
│ ├── *.test.ts # Focused core tests
|
|
59
|
-
│ └── README.md # Test documentation
|
|
60
|
-
└── README.md
|
|
61
|
-
```
|
|
12
|
+
- Use it in standalone apps or with framework adapters.
|
|
13
|
+
- Create structured, request-scoped logs with `createStructuredLog`.
|
|
14
|
+
- Redact common secrets before logs reach output or downstream sinks.
|
|
15
|
+
- Ingest logs from browser and Expo apps into your backend flow.
|
|
16
|
+
- Forward logs to optional connectors such as PostHog, Better Stack, Sentry, Databuddy, and OTLP targets.
|
|
17
|
+
- Built for Bun-first setups with support for supported Node runtimes.
|
|
18
|
+
- Full TypeScript support across the main package and subpath exports.
|
|
62
19
|
|
|
63
20
|
## Installation
|
|
64
21
|
|
|
65
22
|
```bash
|
|
66
23
|
bun add @blyp/core
|
|
67
|
-
npx expo install expo-network
|
|
68
24
|
```
|
|
69
25
|
|
|
70
|
-
|
|
26
|
+
`npm install @blyp/core` | `pnpm add @blyp/core` | `yarn add @blyp/core`
|
|
27
|
+
|
|
28
|
+
If you use the Expo logger, also install `expo-network`.
|
|
71
29
|
|
|
72
|
-
|
|
30
|
+
```bash
|
|
31
|
+
npx expo install expo-network
|
|
32
|
+
```
|
|
73
33
|
|
|
74
|
-
|
|
34
|
+
## Quick start
|
|
75
35
|
|
|
76
|
-
```
|
|
36
|
+
```ts
|
|
77
37
|
import { logger } from '@blyp/core';
|
|
78
38
|
|
|
79
|
-
logger.info('
|
|
80
|
-
logger.success('
|
|
81
|
-
logger.error('
|
|
82
|
-
logger.warning('Warning message');
|
|
39
|
+
logger.info('Server started', { port: 3000 });
|
|
40
|
+
logger.success('Connected to database');
|
|
41
|
+
logger.error('Payment failed', { orderId: 'ord_123' });
|
|
83
42
|
```
|
|
84
43
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
Standalone usage:
|
|
44
|
+
## Structured logs
|
|
88
45
|
|
|
89
|
-
```
|
|
46
|
+
```ts
|
|
90
47
|
import { createStructuredLog } from '@blyp/core';
|
|
91
48
|
|
|
92
|
-
const
|
|
49
|
+
const log = createStructuredLog('checkout', {
|
|
93
50
|
service: 'web-api',
|
|
94
51
|
level: 'info',
|
|
95
52
|
timestamp: new Date().toISOString(),
|
|
96
53
|
});
|
|
97
54
|
|
|
98
|
-
|
|
55
|
+
log.set({
|
|
99
56
|
user: { id: 1, plan: 'pro' },
|
|
100
57
|
cart: { items: 3, total: 9999 },
|
|
101
58
|
});
|
|
102
59
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
structuredLog.emit({ status: 200 });
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
Framework usage with Elysia:
|
|
109
|
-
|
|
110
|
-
```typescript
|
|
111
|
-
import { createStructuredLog } from '@blyp/core';
|
|
112
|
-
import { Elysia } from 'elysia';
|
|
113
|
-
import { createLogger } from '@blyp/core/elysia';
|
|
114
|
-
|
|
115
|
-
const app = new Elysia()
|
|
116
|
-
.use(createLogger({ level: 'info' }))
|
|
117
|
-
.post('/hello', ({ set }) => {
|
|
118
|
-
const structuredLog = createStructuredLog<{
|
|
119
|
-
message: string;
|
|
120
|
-
level: string;
|
|
121
|
-
timestamp: string;
|
|
122
|
-
hostname?: string;
|
|
123
|
-
port?: number;
|
|
124
|
-
}>('test', {
|
|
125
|
-
message: 'Hello Elysia',
|
|
126
|
-
level: 'info',
|
|
127
|
-
timestamp: new Date().toISOString(),
|
|
128
|
-
hostname: app.server?.hostname,
|
|
129
|
-
port: app.server?.port,
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
structuredLog.info('route started');
|
|
133
|
-
structuredLog.emit({ status: 200 });
|
|
134
|
-
|
|
135
|
-
set.status = 200;
|
|
136
|
-
return 'ok';
|
|
137
|
-
});
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
Inside framework handlers, the imported `createStructuredLog(...)` automatically binds to the active request-scoped logger. Structured logs are emitted only when you call `.emit()`. In framework request loggers, a structured emit replaces that request's normal auto request log. If you mix a request-scoped structured logger with the root `logger` in the same request, Blyp warns once and ignores the root logger call.
|
|
141
|
-
|
|
142
|
-
### Errors
|
|
143
|
-
|
|
144
|
-
```typescript
|
|
145
|
-
import { createError } from '@blyp/core';
|
|
146
|
-
|
|
147
|
-
throw createError({ status: 404, message: 'Not found' });
|
|
60
|
+
log.info('checkout started');
|
|
61
|
+
log.emit({ status: 200 });
|
|
148
62
|
```
|
|
149
63
|
|
|
150
|
-
|
|
64
|
+
Inside framework handlers, `createStructuredLog(...)` binds to the active request logger automatically. The final structured record is written when you call `.emit()`.
|
|
151
65
|
|
|
152
|
-
|
|
66
|
+
## Framework example
|
|
153
67
|
|
|
154
|
-
Blyp supports
|
|
68
|
+
Blyp supports Elysia, Hono, Express, Fastify, NestJS, Next.js App Router, React Router, Astro, Nitro, Nuxt, TanStack Start, SvelteKit, and Cloudflare Workers.
|
|
155
69
|
|
|
156
|
-
```
|
|
70
|
+
```ts
|
|
157
71
|
import { Elysia } from 'elysia';
|
|
158
72
|
import { createLogger } from '@blyp/core/elysia';
|
|
159
73
|
|
|
@@ -163,424 +77,42 @@ const app = new Elysia()
|
|
|
163
77
|
.listen(3000);
|
|
164
78
|
```
|
|
165
79
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
### Expo
|
|
169
|
-
|
|
170
|
-
```typescript
|
|
171
|
-
import { createExpoLogger } from '@blyp/core/expo';
|
|
172
|
-
|
|
173
|
-
const logger = createExpoLogger({
|
|
174
|
-
endpoint: 'https://api.example.com/inngest',
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
logger.info('app mounted');
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
Expo uses the runtime `fetch` implementation for delivery and `expo-network` for connectivity metadata. Install `expo-network` in your app and use an absolute ingestion URL.
|
|
181
|
-
|
|
182
|
-
### Database logging
|
|
183
|
-
|
|
184
|
-
Use `destination: 'database'` when you cannot rely on filesystem writes, such as serverless deployments. Database mode requires an executable config file like `blyp.config.ts` because Prisma and Drizzle adapters are runtime objects.
|
|
185
|
-
|
|
186
|
-
Prisma:
|
|
187
|
-
|
|
188
|
-
```typescript
|
|
189
|
-
import { PrismaClient } from '@prisma/client';
|
|
190
|
-
import { createPrismaDatabaseAdapter } from '@blyp/core/database';
|
|
191
|
-
|
|
192
|
-
const prisma = new PrismaClient();
|
|
193
|
-
|
|
194
|
-
export default {
|
|
195
|
-
destination: 'database',
|
|
196
|
-
database: {
|
|
197
|
-
dialect: 'postgres',
|
|
198
|
-
adapter: createPrismaDatabaseAdapter({
|
|
199
|
-
client: prisma,
|
|
200
|
-
model: 'blypLog',
|
|
201
|
-
}),
|
|
202
|
-
},
|
|
203
|
-
};
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
Drizzle:
|
|
207
|
-
|
|
208
|
-
```typescript
|
|
209
|
-
import { createDrizzleDatabaseAdapter } from '@blyp/core/database';
|
|
210
|
-
import { db } from './db';
|
|
211
|
-
import { blypLogs } from './db/schema/blyp';
|
|
212
|
-
|
|
213
|
-
export default {
|
|
214
|
-
destination: 'database',
|
|
215
|
-
database: {
|
|
216
|
-
dialect: 'mysql',
|
|
217
|
-
adapter: createDrizzleDatabaseAdapter({
|
|
218
|
-
db,
|
|
219
|
-
table: blypLogs,
|
|
220
|
-
}),
|
|
221
|
-
},
|
|
222
|
-
};
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
In database mode, Blyp keeps connectors working as usual and replaces only the primary local persistence backend. Promise-based and hook-driven framework integrations such as Hono, Elysia, Next.js, React Router, Astro, Nitro, Nuxt, SvelteKit, and TanStack Start flush database writes before the request finishes. In callback-style servers, call `await logger.flush()` at your own boundary when you need a hard durability point.
|
|
226
|
-
|
|
227
|
-
Use the Blyp CLI to scaffold the schema and migrations:
|
|
228
|
-
|
|
229
|
-
```bash
|
|
230
|
-
blyp logs init --adapter prisma --dialect postgres
|
|
231
|
-
blyp logs init --adapter drizzle --dialect mysql
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
### Better Stack
|
|
235
|
-
|
|
236
|
-
Use `connectors.betterstack` when you want Blyp logs forwarded into Better Stack through `@logtail/node`:
|
|
237
|
-
|
|
238
|
-
```typescript
|
|
239
|
-
export default {
|
|
240
|
-
connectors: {
|
|
241
|
-
betterstack: {
|
|
242
|
-
enabled: true,
|
|
243
|
-
mode: 'auto',
|
|
244
|
-
sourceToken: process.env.SOURCE_TOKEN,
|
|
245
|
-
ingestingHost: process.env.INGESTING_HOST,
|
|
246
|
-
errorTracking: {
|
|
247
|
-
dsn: process.env.BETTERSTACK_ERROR_TRACKING_DSN,
|
|
248
|
-
tracesSampleRate: 1.0,
|
|
249
|
-
},
|
|
250
|
-
},
|
|
251
|
-
},
|
|
252
|
-
};
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
`INGESTING_HOST` must be a full absolute `http://` or `https://` URL. Blyp does not auto-read `SOURCE_TOKEN` or `INGESTING_HOST`; wire them through your config explicitly.
|
|
256
|
-
|
|
257
|
-
In `auto` mode, the normal Blyp server loggers forward to Better Stack automatically. In `manual` mode, use `@blyp/core/betterstack`:
|
|
258
|
-
|
|
259
|
-
```typescript
|
|
260
|
-
import {
|
|
261
|
-
captureBetterStackException,
|
|
262
|
-
createBetterStackErrorTracker,
|
|
263
|
-
createBetterStackLogger,
|
|
264
|
-
createStructuredBetterStackLogger,
|
|
265
|
-
} from '@blyp/core/betterstack';
|
|
266
|
-
|
|
267
|
-
createBetterStackLogger().info('manual better stack log');
|
|
268
|
-
createBetterStackErrorTracker().capture(new Error('manual better stack exception'));
|
|
269
|
-
captureBetterStackException(new Error('wrapped better stack exception'));
|
|
270
|
-
|
|
271
|
-
const structured = createStructuredBetterStackLogger('checkout', {
|
|
272
|
-
orderId: 'ord_123',
|
|
273
|
-
});
|
|
274
|
-
structured.info('manual start');
|
|
275
|
-
structured.emit({ status: 200 });
|
|
276
|
-
```
|
|
277
|
-
|
|
278
|
-
When `connectors.betterstack.errorTracking.dsn` is configured, Blyp captures handled server errors into Better Stack error tracking using the Sentry SDK. Client `error` and `critical` logs requested through the Better Stack connector are promoted to exceptions as well.
|
|
279
|
-
|
|
280
|
-
Browser and Expo loggers can request server-side Better Stack forwarding through the existing ingestion endpoint:
|
|
281
|
-
|
|
282
|
-
```typescript
|
|
283
|
-
import { createClientLogger } from '@blyp/core/client';
|
|
284
|
-
|
|
285
|
-
const logger = createClientLogger({
|
|
286
|
-
endpoint: '/inngest',
|
|
287
|
-
connector: 'betterstack',
|
|
288
|
-
});
|
|
289
|
-
```
|
|
290
|
-
|
|
291
|
-
```typescript
|
|
292
|
-
import { createExpoLogger } from '@blyp/core/expo';
|
|
293
|
-
|
|
294
|
-
const logger = createExpoLogger({
|
|
295
|
-
endpoint: 'https://api.example.com/inngest',
|
|
296
|
-
connector: 'betterstack',
|
|
297
|
-
});
|
|
298
|
-
```
|
|
299
|
-
|
|
300
|
-
The browser and Expo connector flow still posts to Blyp first. Blyp forwards to Better Stack only when the server connector is configured. Browser and Expo apps do not use `@logtail/browser` directly. Workers remain out of scope for this connector.
|
|
301
|
-
|
|
302
|
-
### PostHog
|
|
303
|
-
|
|
304
|
-
Use `blyp.config.ts` when you want to read the PostHog project key from the environment:
|
|
305
|
-
|
|
306
|
-
```typescript
|
|
307
|
-
export default {
|
|
308
|
-
connectors: {
|
|
309
|
-
posthog: {
|
|
310
|
-
enabled: true,
|
|
311
|
-
mode: 'auto',
|
|
312
|
-
projectKey: process.env.POSTHOG_PROJECT_KEY,
|
|
313
|
-
errorTracking: {
|
|
314
|
-
enabled: true,
|
|
315
|
-
mode: 'auto',
|
|
316
|
-
},
|
|
317
|
-
},
|
|
318
|
-
},
|
|
319
|
-
};
|
|
320
|
-
```
|
|
321
|
-
|
|
322
|
-
In `auto` mode, the normal Blyp server loggers forward to PostHog automatically. In `manual` mode, use `@blyp/core/posthog`:
|
|
323
|
-
|
|
324
|
-
```typescript
|
|
325
|
-
import {
|
|
326
|
-
capturePosthogException,
|
|
327
|
-
createPosthogErrorTracker,
|
|
328
|
-
createPosthogLogger,
|
|
329
|
-
createStructuredPosthogLogger,
|
|
330
|
-
} from '@blyp/core/posthog';
|
|
80
|
+
See the [framework integration docs](docs/README.md#framework-integrations) for the full adapter matrix and framework-specific examples.
|
|
331
81
|
|
|
332
|
-
|
|
333
|
-
createPosthogErrorTracker().capture(new Error('manual posthog exception'));
|
|
334
|
-
capturePosthogException(new Error('wrapped posthog exception'));
|
|
335
|
-
|
|
336
|
-
const structured = createStructuredPosthogLogger('checkout', { orderId: 'ord_123' });
|
|
337
|
-
structured.info('manual start');
|
|
338
|
-
structured.emit({ status: 200 });
|
|
339
|
-
```
|
|
82
|
+
## More features
|
|
340
83
|
|
|
341
|
-
|
|
84
|
+
- [Automatic redaction](docs/README.md#automatic-redaction) for common secrets, headers, and custom patterns.
|
|
85
|
+
- [Client and Expo logging](docs/README.md#client) for browser and mobile apps that send logs through your backend.
|
|
86
|
+
- [AI tracing](docs/README.md#ai-sdk-tracing) for Vercel AI SDK, Better Agent, OpenAI, Anthropic, and compatible transports.
|
|
87
|
+
- [Database logging](docs/README.md#database-logging) when file persistence is not the right fit.
|
|
88
|
+
- Connector forwarding for [PostHog](docs/README.md#posthog-connector), [Databuddy](docs/README.md#databuddy-connector), [Better Stack](docs/README.md#better-stack-connector), [Sentry](docs/README.md#sentry-connector), and [OTLP](docs/README.md#otlp-connector).
|
|
342
89
|
|
|
343
|
-
|
|
90
|
+
## Documentation
|
|
344
91
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
Use `connectors.databuddy` when you want Blyp logs and handled errors forwarded into Databuddy:
|
|
361
|
-
|
|
362
|
-
```typescript
|
|
363
|
-
export default {
|
|
364
|
-
connectors: {
|
|
365
|
-
databuddy: {
|
|
366
|
-
enabled: true,
|
|
367
|
-
mode: 'auto',
|
|
368
|
-
apiKey: process.env.DATABUDDY_API_KEY,
|
|
369
|
-
websiteId: process.env.DATABUDDY_WEBSITE_ID,
|
|
370
|
-
enableBatching: true,
|
|
371
|
-
},
|
|
372
|
-
},
|
|
373
|
-
};
|
|
374
|
-
```
|
|
375
|
-
|
|
376
|
-
Databuddy requires both `apiKey` and `websiteId`. Blyp treats the connector as unavailable until both are configured.
|
|
377
|
-
|
|
378
|
-
In `auto` mode, normal Blyp server loggers forward to Databuddy automatically and handled errors are captured as Databuddy `error` events. In `manual` mode, use `@blyp/core/databuddy`:
|
|
379
|
-
|
|
380
|
-
```typescript
|
|
381
|
-
import {
|
|
382
|
-
captureDatabuddyException,
|
|
383
|
-
createDatabuddyErrorTracker,
|
|
384
|
-
createDatabuddyLogger,
|
|
385
|
-
createStructuredDatabuddyLogger,
|
|
386
|
-
} from '@blyp/core/databuddy';
|
|
387
|
-
|
|
388
|
-
createDatabuddyLogger().info('manual databuddy log');
|
|
389
|
-
createDatabuddyErrorTracker().capture(new Error('manual databuddy exception'));
|
|
390
|
-
captureDatabuddyException(new Error('wrapped databuddy exception'));
|
|
391
|
-
|
|
392
|
-
const structured = createStructuredDatabuddyLogger('checkout', { orderId: 'ord_123' });
|
|
393
|
-
structured.info('manual start');
|
|
394
|
-
structured.emit({ status: 200 });
|
|
395
|
-
```
|
|
396
|
-
|
|
397
|
-
Browser and Expo loggers can request server-side Databuddy forwarding through the existing ingestion endpoint:
|
|
398
|
-
|
|
399
|
-
```typescript
|
|
400
|
-
import { createClientLogger } from '@blyp/core/client';
|
|
401
|
-
|
|
402
|
-
const logger = createClientLogger({
|
|
403
|
-
endpoint: '/inngest',
|
|
404
|
-
connector: 'databuddy',
|
|
405
|
-
});
|
|
406
|
-
```
|
|
407
|
-
|
|
408
|
-
Client `error` and `critical` logs requested through the Databuddy connector are promoted to Databuddy `error` events only when server-side Databuddy is enabled in `auto` mode. The client and Expo connector flow still posts to Blyp first. Blyp forwards to Databuddy only when the server connector is configured.
|
|
409
|
-
|
|
410
|
-
### Sentry
|
|
411
|
-
|
|
412
|
-
Use `connectors.sentry` when you want Blyp logs forwarded into Sentry Logs:
|
|
413
|
-
|
|
414
|
-
```typescript
|
|
415
|
-
export default {
|
|
416
|
-
connectors: {
|
|
417
|
-
sentry: {
|
|
418
|
-
enabled: true,
|
|
419
|
-
mode: 'auto',
|
|
420
|
-
dsn: process.env.SENTRY_DSN,
|
|
421
|
-
environment: process.env.SENTRY_ENVIRONMENT,
|
|
422
|
-
release: process.env.SENTRY_RELEASE,
|
|
423
|
-
},
|
|
424
|
-
},
|
|
425
|
-
};
|
|
426
|
-
```
|
|
427
|
-
|
|
428
|
-
In `auto` mode, normal Blyp server loggers forward to Sentry automatically. In `manual` mode, use `@blyp/core/sentry`:
|
|
429
|
-
|
|
430
|
-
```typescript
|
|
431
|
-
import { createSentryLogger, createStructuredSentryLogger } from '@blyp/core/sentry';
|
|
432
|
-
|
|
433
|
-
createSentryLogger().info('manual sentry log');
|
|
434
|
-
|
|
435
|
-
const structured = createStructuredSentryLogger('checkout', {
|
|
436
|
-
orderId: 'ord_123',
|
|
437
|
-
});
|
|
438
|
-
structured.info('manual start');
|
|
439
|
-
structured.emit({ status: 200 });
|
|
440
|
-
```
|
|
441
|
-
|
|
442
|
-
Browser and Expo loggers can request server-side forwarding through Blyp's ingestion endpoint:
|
|
443
|
-
|
|
444
|
-
```typescript
|
|
445
|
-
import { createClientLogger } from '@blyp/core/client';
|
|
446
|
-
|
|
447
|
-
const logger = createClientLogger({
|
|
448
|
-
endpoint: '/inngest',
|
|
449
|
-
connector: 'sentry',
|
|
450
|
-
});
|
|
451
|
-
```
|
|
452
|
-
|
|
453
|
-
```typescript
|
|
454
|
-
import { createExpoLogger } from '@blyp/core/expo';
|
|
455
|
-
|
|
456
|
-
const logger = createExpoLogger({
|
|
457
|
-
endpoint: 'https://api.example.com/inngest',
|
|
458
|
-
connector: 'sentry',
|
|
459
|
-
});
|
|
460
|
-
```
|
|
461
|
-
|
|
462
|
-
The browser and Expo Sentry flow still posts to Blyp first. Blyp forwards to Sentry only when the server connector is configured. If Sentry was already initialized by the app, Blyp reuses that client instead of replacing it.
|
|
463
|
-
|
|
464
|
-
### OTLP
|
|
465
|
-
|
|
466
|
-
Use `connectors.otlp` when you want to send logs to named OTLP-compatible backends such as Grafana Cloud, Datadog, Honeycomb, or a self-hosted OpenTelemetry Collector:
|
|
467
|
-
|
|
468
|
-
```typescript
|
|
469
|
-
export default {
|
|
470
|
-
connectors: {
|
|
471
|
-
otlp: [
|
|
472
|
-
{
|
|
473
|
-
name: 'grafana',
|
|
474
|
-
enabled: true,
|
|
475
|
-
mode: 'auto',
|
|
476
|
-
endpoint: 'http://localhost:4318',
|
|
477
|
-
headers: {
|
|
478
|
-
'x-scope-orgid': process.env.GRAFANA_SCOPE_ID!,
|
|
479
|
-
},
|
|
480
|
-
auth: process.env.GRAFANA_AUTH,
|
|
481
|
-
},
|
|
482
|
-
{
|
|
483
|
-
name: 'honeycomb',
|
|
484
|
-
enabled: true,
|
|
485
|
-
mode: 'manual',
|
|
486
|
-
endpoint: 'https://api.honeycomb.io',
|
|
487
|
-
headers: {
|
|
488
|
-
'x-honeycomb-team': process.env.HONEYCOMB_API_KEY!,
|
|
489
|
-
},
|
|
490
|
-
},
|
|
491
|
-
],
|
|
492
|
-
},
|
|
493
|
-
};
|
|
494
|
-
```
|
|
495
|
-
|
|
496
|
-
In `auto` mode, normal Blyp server loggers forward to every ready OTLP target automatically. In `manual` mode, use `@blyp/core/otlp` and select a named target:
|
|
497
|
-
|
|
498
|
-
```typescript
|
|
499
|
-
import { createOtlpLogger, createStructuredOtlpLogger } from '@blyp/core/otlp';
|
|
500
|
-
|
|
501
|
-
createOtlpLogger({
|
|
502
|
-
name: 'grafana',
|
|
503
|
-
}).info('manual otlp log');
|
|
504
|
-
|
|
505
|
-
const structured = createStructuredOtlpLogger(
|
|
506
|
-
'checkout',
|
|
507
|
-
{ orderId: 'ord_123' },
|
|
508
|
-
{ name: 'honeycomb' }
|
|
509
|
-
);
|
|
510
|
-
structured.info('manual start');
|
|
511
|
-
structured.emit({ status: 200 });
|
|
512
|
-
```
|
|
513
|
-
|
|
514
|
-
Browser and Expo loggers can request server-side forwarding to a named OTLP target through the existing ingestion endpoint:
|
|
515
|
-
|
|
516
|
-
```typescript
|
|
517
|
-
import { createClientLogger } from '@blyp/core/client';
|
|
518
|
-
|
|
519
|
-
const logger = createClientLogger({
|
|
520
|
-
endpoint: '/inngest',
|
|
521
|
-
connector: { type: 'otlp', name: 'grafana' },
|
|
522
|
-
});
|
|
523
|
-
```
|
|
524
|
-
|
|
525
|
-
```typescript
|
|
526
|
-
import { createExpoLogger } from '@blyp/core/expo';
|
|
527
|
-
|
|
528
|
-
const logger = createExpoLogger({
|
|
529
|
-
endpoint: 'https://api.example.com/inngest',
|
|
530
|
-
connector: { type: 'otlp', name: 'grafana' },
|
|
531
|
-
});
|
|
532
|
-
```
|
|
533
|
-
|
|
534
|
-
The browser and Expo OTLP flows still post to Blyp first. Blyp forwards to the named OTLP target only when that server connector is configured and ready.
|
|
535
|
-
|
|
536
|
-
Log levels, HTTP request logging, and file logging (rotation, archives, reading stored logs) are documented in [docs](docs/README.md#file-logging).
|
|
537
|
-
|
|
538
|
-
## Testing
|
|
539
|
-
|
|
540
|
-
Run tests:
|
|
541
|
-
|
|
542
|
-
```bash
|
|
543
|
-
bun run test
|
|
544
|
-
```
|
|
545
|
-
|
|
546
|
-
The suite covers runtime detection, standalone and client logger, file logging, and all framework integrations. For more commands and previews, see [tests/README.md](tests/README.md).
|
|
92
|
+
- [Full documentation](docs/README.md)
|
|
93
|
+
- [Framework integrations](docs/README.md#framework-integrations)
|
|
94
|
+
- [Client and Expo logging](docs/README.md#client)
|
|
95
|
+
- [AI tracing](docs/README.md#ai-sdk-tracing)
|
|
96
|
+
- [Database logging](docs/README.md#database-logging)
|
|
97
|
+
- [PostHog connector](docs/README.md#posthog-connector)
|
|
98
|
+
- [Databuddy connector](docs/README.md#databuddy-connector)
|
|
99
|
+
- [Better Stack connector](docs/README.md#better-stack-connector)
|
|
100
|
+
- [Sentry connector](docs/README.md#sentry-connector)
|
|
101
|
+
- [OTLP connector](docs/README.md#otlp-connector)
|
|
102
|
+
- [Stability policy](STABILITY.md)
|
|
103
|
+
- [Security policy](SECURITY.md)
|
|
104
|
+
- [Contributing](CONTRIBUTING.md)
|
|
105
|
+
- [Test docs](tests/README.md)
|
|
547
106
|
|
|
548
107
|
## Development
|
|
549
108
|
|
|
550
|
-
**Prerequisites:** [Bun](https://bun.sh) 1.2+ (or [Node.js](https://nodejs.org) 18+), [TypeScript](https://www.typescriptlang.org) 5.0+
|
|
551
|
-
|
|
552
109
|
```bash
|
|
553
|
-
git clone https://github.com/Blyphq/blyp.git
|
|
554
|
-
cd blyp
|
|
555
110
|
bun install
|
|
556
111
|
bun run test
|
|
557
112
|
bun run build
|
|
558
113
|
bun run type-check
|
|
559
114
|
```
|
|
560
115
|
|
|
561
|
-
## Publishing
|
|
562
|
-
|
|
563
|
-
GitHub Actions publishes the package to npm when a GitHub Release is published. Add an `NPM_TOKEN` repository secret before using the workflow.
|
|
564
|
-
|
|
565
|
-
## Contributing
|
|
566
|
-
|
|
567
|
-
Contributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for how to get set up and submit changes.
|
|
568
|
-
|
|
569
116
|
## License
|
|
570
117
|
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
## Acknowledgments
|
|
574
|
-
|
|
575
|
-
[Winston](https://github.com/winstonjs/winston) · [Elysia](https://elysiajs.com) · [Chalk](https://github.com/chalk/chalk) · [Bun](https://bun.sh)
|
|
576
|
-
|
|
577
|
-
## Links
|
|
578
|
-
|
|
579
|
-
- [GitHub Repository](https://github.com/Blyphq/blyp)
|
|
580
|
-
- [NPM Package](https://www.npmjs.com/package/@blyp/core)
|
|
581
|
-
- [Documentation](docs/README.md)
|
|
582
|
-
- [Issues](https://github.com/Blyphq/blyp/issues)
|
|
583
|
-
|
|
584
|
-
---
|
|
585
|
-
|
|
586
|
-
*Blyp silently watches over your applications, logging everything that happens under its watchful gaze.*
|
|
118
|
+
MIT
|