@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.
Files changed (248) hide show
  1. package/README.md +54 -522
  2. package/STABILITY.md +56 -0
  3. package/dist/ai/anthropic/index.d.ts +3 -0
  4. package/dist/ai/anthropic/normalize.d.ts +9 -0
  5. package/dist/ai/anthropic/stream.d.ts +3 -0
  6. package/dist/ai/anthropic/wrap.d.ts +13 -0
  7. package/dist/ai/anthropic.js +701 -0
  8. package/dist/ai/anthropic.mjs +701 -0
  9. package/dist/ai/better-agent/index.d.ts +3 -0
  10. package/dist/ai/better-agent/normalize.d.ts +18 -0
  11. package/dist/ai/better-agent/plugin.d.ts +3 -0
  12. package/dist/ai/better-agent/tracker.d.ts +35 -0
  13. package/dist/ai/better-agent.js +701 -0
  14. package/dist/ai/better-agent.mjs +701 -0
  15. package/dist/ai/fetch.js +701 -0
  16. package/dist/ai/fetch.mjs +701 -0
  17. package/dist/ai/openai/index.d.ts +3 -0
  18. package/dist/ai/openai/normalize.d.ts +10 -0
  19. package/dist/ai/openai/stream.d.ts +3 -0
  20. package/dist/ai/openai/wrap.d.ts +24 -0
  21. package/dist/ai/openai.js +701 -0
  22. package/dist/ai/openai.mjs +701 -0
  23. package/dist/ai/shared/fetch.d.ts +5 -0
  24. package/dist/ai/shared/index.d.ts +2 -0
  25. package/dist/ai/shared/normalize.d.ts +17 -0
  26. package/dist/ai/shared/redaction.d.ts +6 -0
  27. package/dist/ai/shared/stream.d.ts +7 -0
  28. package/dist/ai/shared/trace.d.ts +119 -0
  29. package/dist/ai/shared/types.d.ts +171 -0
  30. package/dist/ai/shared.js +701 -0
  31. package/dist/ai/shared.mjs +701 -0
  32. package/dist/ai/vercel/index.d.ts +3 -0
  33. package/dist/ai/vercel/middleware.d.ts +3 -0
  34. package/dist/ai/vercel/model.d.ts +3 -0
  35. package/dist/ai/vercel.js +701 -0
  36. package/dist/ai/vercel.mjs +701 -0
  37. package/dist/astro.js +618 -4519
  38. package/dist/astro.mjs +618 -4491
  39. package/dist/client.js +1 -1139
  40. package/dist/client.mjs +1 -1132
  41. package/dist/connectors/betterstack.js +9 -1532
  42. package/dist/connectors/betterstack.mjs +9 -1507
  43. package/dist/connectors/databuddy.js +9 -1456
  44. package/dist/connectors/databuddy.mjs +9 -1451
  45. package/dist/connectors/delivery/backoff.d.ts +2 -0
  46. package/dist/connectors/delivery/manager.d.ts +44 -0
  47. package/dist/connectors/delivery/queue-path.d.ts +1 -0
  48. package/dist/connectors/delivery/sqlite-adapter-bun.d.ts +1 -0
  49. package/dist/connectors/delivery/sqlite-adapter-node.d.ts +1 -0
  50. package/dist/connectors/delivery/sqlite-client.d.ts +37 -0
  51. package/dist/connectors/delivery/sqlite-worker.d.ts +1 -0
  52. package/dist/connectors/delivery/studio-queue.d.ts +12 -0
  53. package/dist/connectors/delivery/types.d.ts +98 -0
  54. package/dist/connectors/otlp/index.d.ts +1 -0
  55. package/dist/connectors/otlp.js +9 -1371
  56. package/dist/connectors/otlp.mjs +9 -1368
  57. package/dist/connectors/posthog/properties.d.ts +4 -0
  58. package/dist/connectors/posthog/sender.d.ts +0 -1
  59. package/dist/connectors/posthog.js +10 -1527
  60. package/dist/connectors/posthog.mjs +10 -1522
  61. package/dist/connectors/sentry.js +9 -1380
  62. package/dist/connectors/sentry.mjs +9 -1357
  63. package/dist/core/config.d.ts +7 -2
  64. package/dist/core/log-record.d.ts +5 -4
  65. package/dist/core/logger.d.ts +2 -0
  66. package/dist/core/optional-module.d.ts +1 -0
  67. package/dist/core/pino-pretty-loader.d.ts +4 -0
  68. package/dist/database.js +1 -24
  69. package/dist/database.mjs +1 -21
  70. package/dist/elysia.js +613 -4517
  71. package/dist/elysia.mjs +615 -4491
  72. package/dist/expo.js +1 -726
  73. package/dist/expo.mjs +1 -724
  74. package/dist/express.js +613 -4507
  75. package/dist/express.mjs +615 -4480
  76. package/dist/fastify.js +615 -4526
  77. package/dist/fastify.mjs +617 -4499
  78. package/dist/frameworks/elysia/index.d.ts +1 -1
  79. package/dist/frameworks/elysia/logger.d.ts +2 -35
  80. package/dist/frameworks/nestjs/helpers.d.ts +2 -0
  81. package/dist/frameworks/shared/http.d.ts +3 -2
  82. package/dist/frameworks/shared/index.d.ts +2 -1
  83. package/dist/frameworks/shared/logger.d.ts +2 -0
  84. package/dist/frameworks/shared/request-context.d.ts +2 -0
  85. package/dist/frameworks/shared/trace.d.ts +6 -0
  86. package/dist/hono.js +616 -4496
  87. package/dist/hono.mjs +618 -4470
  88. package/dist/index.d.ts +49 -19
  89. package/dist/index.js +615 -7557
  90. package/dist/index.mjs +618 -7465
  91. package/dist/nestjs.js +626 -4999
  92. package/dist/nestjs.mjs +621 -4966
  93. package/dist/nextjs.js +618 -4525
  94. package/dist/nextjs.mjs +620 -4499
  95. package/dist/nitro.js +617 -4642
  96. package/dist/nitro.mjs +619 -4616
  97. package/dist/nuxt.js +617 -4649
  98. package/dist/nuxt.mjs +619 -4623
  99. package/dist/react-router.js +616 -4559
  100. package/dist/react-router.mjs +618 -4533
  101. package/dist/shared/redaction.d.ts +17 -0
  102. package/dist/standalone.js +606 -3628
  103. package/dist/standalone.mjs +610 -3603
  104. package/dist/sveltekit.js +617 -4523
  105. package/dist/sveltekit.mjs +619 -4497
  106. package/dist/tanstack-start.js +616 -4522
  107. package/dist/tanstack-start.mjs +618 -4496
  108. package/dist/types/core/config.d.ts +57 -0
  109. package/dist/types/core/logger.d.ts +3 -0
  110. package/dist/types/core/structured-log.d.ts +2 -0
  111. package/dist/types/database.d.ts +1 -0
  112. package/dist/types/frameworks/astro.d.ts +1 -0
  113. package/dist/types/frameworks/client.d.ts +2 -0
  114. package/dist/types/frameworks/elysia.d.ts +2 -0
  115. package/dist/types/frameworks/express.d.ts +1 -0
  116. package/dist/types/frameworks/fastify.d.ts +1 -0
  117. package/dist/types/frameworks/hono.d.ts +1 -0
  118. package/dist/types/frameworks/http.d.ts +1 -0
  119. package/dist/types/frameworks/nestjs.d.ts +2 -0
  120. package/dist/types/frameworks/nextjs.d.ts +1 -0
  121. package/dist/types/frameworks/nitro.d.ts +1 -0
  122. package/dist/types/frameworks/react-router.d.ts +2 -0
  123. package/dist/types/frameworks/request-context.d.ts +1 -0
  124. package/dist/types/frameworks/shared.d.ts +4 -1
  125. package/dist/types/frameworks/standalone.d.ts +3 -2
  126. package/dist/types/frameworks/sveltekit.d.ts +1 -0
  127. package/dist/types/frameworks/tanstack-start.d.ts +9 -3
  128. package/dist/types/frameworks/workers.d.ts +3 -0
  129. package/dist/types/shared/client-log.d.ts +1 -0
  130. package/dist/workers.js +2 -626
  131. package/dist/workers.mjs +2 -623
  132. package/package.json +259 -173
  133. package/dist/astro.js.map +0 -1
  134. package/dist/astro.mjs.map +0 -1
  135. package/dist/client.js.map +0 -1
  136. package/dist/client.mjs.map +0 -1
  137. package/dist/connectors/betterstack.js.map +0 -1
  138. package/dist/connectors/betterstack.mjs.map +0 -1
  139. package/dist/connectors/databuddy.js.map +0 -1
  140. package/dist/connectors/databuddy.mjs.map +0 -1
  141. package/dist/connectors/otlp.js.map +0 -1
  142. package/dist/connectors/otlp.mjs.map +0 -1
  143. package/dist/connectors/posthog.js.map +0 -1
  144. package/dist/connectors/posthog.mjs.map +0 -1
  145. package/dist/connectors/sentry.js.map +0 -1
  146. package/dist/connectors/sentry.mjs.map +0 -1
  147. package/dist/database.js.map +0 -1
  148. package/dist/database.mjs.map +0 -1
  149. package/dist/elysia.js.map +0 -1
  150. package/dist/elysia.mjs.map +0 -1
  151. package/dist/expo.js.map +0 -1
  152. package/dist/expo.mjs.map +0 -1
  153. package/dist/express.js.map +0 -1
  154. package/dist/express.mjs.map +0 -1
  155. package/dist/fastify.js.map +0 -1
  156. package/dist/fastify.mjs.map +0 -1
  157. package/dist/hono.js.map +0 -1
  158. package/dist/hono.mjs.map +0 -1
  159. package/dist/index.js.map +0 -1
  160. package/dist/index.mjs.map +0 -1
  161. package/dist/nestjs.js.map +0 -1
  162. package/dist/nestjs.mjs.map +0 -1
  163. package/dist/nextjs.js.map +0 -1
  164. package/dist/nextjs.mjs.map +0 -1
  165. package/dist/nitro.js.map +0 -1
  166. package/dist/nitro.mjs.map +0 -1
  167. package/dist/nuxt.js.map +0 -1
  168. package/dist/nuxt.mjs.map +0 -1
  169. package/dist/react-router.js.map +0 -1
  170. package/dist/react-router.mjs.map +0 -1
  171. package/dist/standalone.js.map +0 -1
  172. package/dist/standalone.mjs.map +0 -1
  173. package/dist/sveltekit.js.map +0 -1
  174. package/dist/sveltekit.mjs.map +0 -1
  175. package/dist/tanstack-start.js.map +0 -1
  176. package/dist/tanstack-start.mjs.map +0 -1
  177. package/dist/workers.js.map +0 -1
  178. package/dist/workers.mjs.map +0 -1
  179. package/exports/client.js +0 -3
  180. package/exports/client.mjs +0 -3
  181. package/exports/connectors/betterstack.js +0 -1
  182. package/exports/connectors/betterstack.mjs +0 -1
  183. package/exports/connectors/databuddy.js +0 -1
  184. package/exports/connectors/databuddy.mjs +0 -1
  185. package/exports/connectors/otlp.js +0 -1
  186. package/exports/connectors/otlp.mjs +0 -1
  187. package/exports/connectors/posthog.js +0 -1
  188. package/exports/connectors/posthog.mjs +0 -1
  189. package/exports/connectors/sentry.js +0 -1
  190. package/exports/connectors/sentry.mjs +0 -1
  191. package/exports/database.js +0 -1
  192. package/exports/database.mjs +0 -1
  193. package/exports/expo.js +0 -1
  194. package/exports/expo.mjs +0 -1
  195. package/exports/frameworks/astro.js +0 -1
  196. package/exports/frameworks/astro.mjs +0 -1
  197. package/exports/frameworks/elysia.js +0 -1
  198. package/exports/frameworks/elysia.mjs +0 -1
  199. package/exports/frameworks/express.js +0 -1
  200. package/exports/frameworks/express.mjs +0 -1
  201. package/exports/frameworks/fastify.js +0 -1
  202. package/exports/frameworks/fastify.mjs +0 -1
  203. package/exports/frameworks/hono.js +0 -1
  204. package/exports/frameworks/hono.mjs +0 -1
  205. package/exports/frameworks/nestjs.js +0 -1
  206. package/exports/frameworks/nestjs.mjs +0 -1
  207. package/exports/frameworks/nextjs.js +0 -1
  208. package/exports/frameworks/nextjs.mjs +0 -1
  209. package/exports/frameworks/nitro.js +0 -1
  210. package/exports/frameworks/nitro.mjs +0 -1
  211. package/exports/frameworks/nuxt.js +0 -1
  212. package/exports/frameworks/nuxt.mjs +0 -1
  213. package/exports/frameworks/react-router.js +0 -1
  214. package/exports/frameworks/react-router.mjs +0 -1
  215. package/exports/frameworks/standalone.js +0 -1
  216. package/exports/frameworks/standalone.mjs +0 -1
  217. package/exports/frameworks/sveltekit.js +0 -1
  218. package/exports/frameworks/sveltekit.mjs +0 -1
  219. package/exports/frameworks/tanstack-start.js +0 -1
  220. package/exports/frameworks/tanstack-start.mjs +0 -1
  221. package/exports/workers.js +0 -1
  222. package/exports/workers.mjs +0 -1
  223. package/types/client.d.ts +0 -34
  224. package/types/connectors/betterstack.d.ts +0 -1
  225. package/types/connectors/databuddy.d.ts +0 -1
  226. package/types/connectors/otlp.d.ts +0 -1
  227. package/types/connectors/posthog.d.ts +0 -1
  228. package/types/connectors/sentry.d.ts +0 -1
  229. package/types/database.d.ts +0 -1
  230. package/types/expo.d.ts +0 -17
  231. package/types/frameworks/astro.d.ts +0 -1
  232. package/types/frameworks/client.d.ts +0 -160
  233. package/types/frameworks/elysia.d.ts +0 -1
  234. package/types/frameworks/expo.d.ts +0 -50
  235. package/types/frameworks/express.d.ts +0 -1
  236. package/types/frameworks/fastify.d.ts +0 -1
  237. package/types/frameworks/hono.d.ts +0 -1
  238. package/types/frameworks/nestjs.d.ts +0 -1
  239. package/types/frameworks/nextjs.d.ts +0 -1
  240. package/types/frameworks/nitro.d.ts +0 -1
  241. package/types/frameworks/nuxt.d.ts +0 -1
  242. package/types/frameworks/react-router.d.ts +0 -1
  243. package/types/frameworks/standalone.d.ts +0 -1
  244. package/types/frameworks/sveltekit.d.ts +0 -1
  245. package/types/frameworks/tanstack-start.d.ts +0 -1
  246. package/types/frameworks/workers.d.ts +0 -115
  247. package/types/index.d.ts +0 -1
  248. package/types/workers.d.ts +0 -13
package/README.md CHANGED
@@ -1,159 +1,73 @@
1
1
  # Blyp Logger
2
2
 
3
- > **Blyp HQ** (`Blyphq`) is the GitHub org behind the Blyp project.
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
  [![Bun](https://img.shields.io/badge/Bun-1.2+-000000?style=flat&logo=bun)](https://bun.sh)
10
7
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-3178C6?style=flat&logo=typescript)](https://www.typescriptlang.org)
11
8
  [![Elysia](https://img.shields.io/badge/Elysia-1.4+-00D8FF?style=flat)](https://elysiajs.com)
12
9
 
13
- ## Features
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
- ## Project structure
28
-
29
- ```
30
- blyp/
31
- ├── exports/
32
- │ ├── client.js # Public client entry shim
33
- │ ├── connectors/
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
- Also: `npm install @blyp/core` | `yarn add @blyp/core` | `pnpm add @blyp/core`
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
- ## Usage
30
+ ```bash
31
+ npx expo install expo-network
32
+ ```
73
33
 
74
- ### Basic logger
34
+ ## Quick start
75
35
 
76
- ```typescript
36
+ ```ts
77
37
  import { logger } from '@blyp/core';
78
38
 
79
- logger.info('Hello world');
80
- logger.success('Operation completed');
81
- logger.error('Something went wrong');
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
- ### Structured request batches
86
-
87
- Standalone usage:
44
+ ## Structured logs
88
45
 
89
- ```typescript
46
+ ```ts
90
47
  import { createStructuredLog } from '@blyp/core';
91
48
 
92
- const structuredLog = createStructuredLog('checkout', {
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
- structuredLog.set({
55
+ log.set({
99
56
  user: { id: 1, plan: 'pro' },
100
57
  cart: { items: 3, total: 9999 },
101
58
  });
102
59
 
103
- structuredLog.info('user logged in');
104
- structuredLog.info('item added to cart');
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
- For the full error API (`HTTP_CODES`, `extend`, `create`), see [Full documentation](docs/README.md#errors).
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
- ### Framework integrations
66
+ ## Framework example
153
67
 
154
- Blyp supports **Elysia**, **Hono**, **Express**, **Fastify**, **NestJS**, **Next.js**, **React Router**, **Astro**, **Nitro**, **Nuxt**, **TanStack Start**, **SvelteKit**, and **Cloudflare Workers**. Example with Elysia:
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
- ```typescript
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
- For other frameworks, client logging, advanced configuration, and utilities, see [Full documentation](docs/README.md).
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
- createPosthogLogger().info('manual posthog log');
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
- `connectors.posthog.errorTracking.mode: 'auto'` also captures Blyp handled server errors and can enable uncaught exception / unhandled rejection autocapture through `enableExceptionAutocapture`.
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
- Browser and Expo loggers can request server-side PostHog forwarding through the existing ingestion endpoint:
90
+ ## Documentation
344
91
 
345
- ```typescript
346
- import { createClientLogger } from '@blyp/core/client';
347
-
348
- const logger = createClientLogger({
349
- endpoint: '/inngest',
350
- connector: 'posthog',
351
- });
352
- ```
353
-
354
- Client `error` and `critical` logs requested through the PostHog connector are promoted to PostHog exceptions only when server-side PostHog error tracking is enabled in `auto` mode.
355
-
356
- The client and Expo connector flow still posts to Blyp first. Blyp forwards to PostHog only when the server connector is configured, and browser or Expo apps do not use `posthog-node` directly. Workers remain out of scope for this connector.
357
-
358
- ### Databuddy
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
- This project is licensed under the MIT License — see the [LICENSE](LICENSE) file for details.
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