@blyp/core 0.1.2

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 (235) hide show
  1. package/README.md +533 -0
  2. package/dist/client.js +1132 -0
  3. package/dist/client.js.map +1 -0
  4. package/dist/client.mjs +1125 -0
  5. package/dist/client.mjs.map +1 -0
  6. package/dist/connectors/betterstack/index.d.ts +7 -0
  7. package/dist/connectors/betterstack/sender.d.ts +5 -0
  8. package/dist/connectors/betterstack.js +1508 -0
  9. package/dist/connectors/betterstack.js.map +1 -0
  10. package/dist/connectors/betterstack.mjs +1483 -0
  11. package/dist/connectors/betterstack.mjs.map +1 -0
  12. package/dist/connectors/otlp/index.d.ts +5 -0
  13. package/dist/connectors/otlp/sender.d.ts +7 -0
  14. package/dist/connectors/otlp.js +1347 -0
  15. package/dist/connectors/otlp.js.map +1 -0
  16. package/dist/connectors/otlp.mjs +1344 -0
  17. package/dist/connectors/otlp.mjs.map +1 -0
  18. package/dist/connectors/posthog/index.d.ts +7 -0
  19. package/dist/connectors/posthog/sender.d.ts +11 -0
  20. package/dist/connectors/posthog.js +1503 -0
  21. package/dist/connectors/posthog.js.map +1 -0
  22. package/dist/connectors/posthog.mjs +1498 -0
  23. package/dist/connectors/posthog.mjs.map +1 -0
  24. package/dist/connectors/sentry/index.d.ts +5 -0
  25. package/dist/connectors/sentry/sender.d.ts +5 -0
  26. package/dist/connectors/sentry.js +1356 -0
  27. package/dist/connectors/sentry.js.map +1 -0
  28. package/dist/connectors/sentry.mjs +1333 -0
  29. package/dist/connectors/sentry.mjs.map +1 -0
  30. package/dist/connectors/shared.d.ts +8 -0
  31. package/dist/core/colors.d.ts +30 -0
  32. package/dist/core/config.d.ts +18 -0
  33. package/dist/core/errors.d.ts +8 -0
  34. package/dist/core/file-logger.d.ts +19 -0
  35. package/dist/core/helpers.d.ts +5 -0
  36. package/dist/core/index.d.ts +8 -0
  37. package/dist/core/log-reader.d.ts +5 -0
  38. package/dist/core/log-record.d.ts +14 -0
  39. package/dist/core/logger.d.ts +20 -0
  40. package/dist/core/primary-sink.d.ts +10 -0
  41. package/dist/core/runtime.d.ts +4 -0
  42. package/dist/core/sinks/database-primary-sink.d.ts +25 -0
  43. package/dist/core/sinks/file-primary-sink.d.ts +14 -0
  44. package/dist/core/structured-log.d.ts +3 -0
  45. package/dist/database/adapters/drizzle.d.ts +7 -0
  46. package/dist/database/adapters/prisma.d.ts +9 -0
  47. package/dist/database/helpers.d.ts +5 -0
  48. package/dist/database/index.d.ts +3 -0
  49. package/dist/database.js +24 -0
  50. package/dist/database.js.map +1 -0
  51. package/dist/database.mjs +21 -0
  52. package/dist/database.mjs.map +1 -0
  53. package/dist/elysia.js +4180 -0
  54. package/dist/elysia.js.map +1 -0
  55. package/dist/elysia.mjs +4152 -0
  56. package/dist/elysia.mjs.map +1 -0
  57. package/dist/expo.js +719 -0
  58. package/dist/expo.js.map +1 -0
  59. package/dist/expo.mjs +717 -0
  60. package/dist/expo.mjs.map +1 -0
  61. package/dist/express.js +4170 -0
  62. package/dist/express.js.map +1 -0
  63. package/dist/express.mjs +4141 -0
  64. package/dist/express.mjs.map +1 -0
  65. package/dist/fastify.js +4187 -0
  66. package/dist/fastify.js.map +1 -0
  67. package/dist/fastify.mjs +4158 -0
  68. package/dist/fastify.mjs.map +1 -0
  69. package/dist/frameworks/client/index.d.ts +3 -0
  70. package/dist/frameworks/client/logger.d.ts +4 -0
  71. package/dist/frameworks/elysia/index.d.ts +2 -0
  72. package/dist/frameworks/elysia/logger.d.ts +35 -0
  73. package/dist/frameworks/expo/index.d.ts +2 -0
  74. package/dist/frameworks/expo/logger.d.ts +3 -0
  75. package/dist/frameworks/expo/network.d.ts +7 -0
  76. package/dist/frameworks/express/index.d.ts +2 -0
  77. package/dist/frameworks/express/logger.d.ts +5 -0
  78. package/dist/frameworks/fastify/index.d.ts +2 -0
  79. package/dist/frameworks/fastify/logger.d.ts +4 -0
  80. package/dist/frameworks/hono/index.d.ts +2 -0
  81. package/dist/frameworks/hono/logger.d.ts +4 -0
  82. package/dist/frameworks/nestjs/constants.d.ts +2 -0
  83. package/dist/frameworks/nestjs/filter.d.ts +8 -0
  84. package/dist/frameworks/nestjs/helpers.d.ts +25 -0
  85. package/dist/frameworks/nestjs/index.d.ts +3 -0
  86. package/dist/frameworks/nestjs/interceptor.d.ts +8 -0
  87. package/dist/frameworks/nestjs/logger.d.ts +6 -0
  88. package/dist/frameworks/nestjs/middleware.d.ts +8 -0
  89. package/dist/frameworks/nestjs/module.d.ts +5 -0
  90. package/dist/frameworks/nextjs/index.d.ts +2 -0
  91. package/dist/frameworks/nextjs/logger.d.ts +3 -0
  92. package/dist/frameworks/shared/http.d.ts +10 -0
  93. package/dist/frameworks/shared/index.d.ts +5 -0
  94. package/dist/frameworks/shared/logger.d.ts +35 -0
  95. package/dist/frameworks/shared/request-context.d.ts +12 -0
  96. package/dist/frameworks/shared/request-logger.d.ts +4 -0
  97. package/dist/frameworks/standalone/index.d.ts +3 -0
  98. package/dist/frameworks/standalone/logger.d.ts +5 -0
  99. package/dist/frameworks/sveltekit/index.d.ts +2 -0
  100. package/dist/frameworks/sveltekit/logger.d.ts +3 -0
  101. package/dist/frameworks/tanstack-start/index.d.ts +2 -0
  102. package/dist/frameworks/tanstack-start/logger.d.ts +3 -0
  103. package/dist/frameworks/workers/index.d.ts +2 -0
  104. package/dist/frameworks/workers/logger.d.ts +3 -0
  105. package/dist/hono.js +4156 -0
  106. package/dist/hono.js.map +1 -0
  107. package/dist/hono.mjs +4128 -0
  108. package/dist/hono.mjs.map +1 -0
  109. package/dist/index.d.ts +47 -0
  110. package/dist/index.js +6581 -0
  111. package/dist/index.js.map +1 -0
  112. package/dist/index.mjs +6494 -0
  113. package/dist/index.mjs.map +1 -0
  114. package/dist/nestjs.js +4649 -0
  115. package/dist/nestjs.js.map +1 -0
  116. package/dist/nestjs.mjs +4621 -0
  117. package/dist/nestjs.mjs.map +1 -0
  118. package/dist/nextjs.js +4183 -0
  119. package/dist/nextjs.js.map +1 -0
  120. package/dist/nextjs.mjs +4155 -0
  121. package/dist/nextjs.mjs.map +1 -0
  122. package/dist/shared/client-log.d.ts +14 -0
  123. package/dist/shared/errors.d.ts +296 -0
  124. package/dist/shared/log-value.d.ts +3 -0
  125. package/dist/shared/once.d.ts +4 -0
  126. package/dist/shared/remote-delivery.d.ts +6 -0
  127. package/dist/shared/validation.d.ts +7 -0
  128. package/dist/standalone.js +3353 -0
  129. package/dist/standalone.js.map +1 -0
  130. package/dist/standalone.mjs +3324 -0
  131. package/dist/standalone.mjs.map +1 -0
  132. package/dist/sveltekit.js +4182 -0
  133. package/dist/sveltekit.js.map +1 -0
  134. package/dist/sveltekit.mjs +4154 -0
  135. package/dist/sveltekit.mjs.map +1 -0
  136. package/dist/tanstack-start.js +4182 -0
  137. package/dist/tanstack-start.js.map +1 -0
  138. package/dist/tanstack-start.mjs +4154 -0
  139. package/dist/tanstack-start.mjs.map +1 -0
  140. package/dist/types/connectors/betterstack.d.ts +54 -0
  141. package/dist/types/connectors/mode.d.ts +2 -0
  142. package/dist/types/connectors/otlp.d.ts +50 -0
  143. package/dist/types/connectors/posthog.d.ts +75 -0
  144. package/dist/types/connectors/sentry.d.ts +48 -0
  145. package/dist/types/core/config.d.ts +152 -0
  146. package/dist/types/core/errors.d.ts +16 -0
  147. package/dist/types/core/file-logger.d.ts +29 -0
  148. package/dist/types/core/helpers.d.ts +8 -0
  149. package/dist/types/core/index.d.ts +8 -0
  150. package/dist/types/core/log-reader.d.ts +4 -0
  151. package/dist/types/core/log-record.d.ts +1 -0
  152. package/dist/types/core/logger.d.ts +40 -0
  153. package/dist/types/core/structured-log.d.ts +57 -0
  154. package/dist/types/database.d.ts +73 -0
  155. package/dist/types/frameworks/client.d.ts +32 -0
  156. package/dist/types/frameworks/elysia.d.ts +33 -0
  157. package/dist/types/frameworks/expo.d.ts +44 -0
  158. package/dist/types/frameworks/express.d.ts +24 -0
  159. package/dist/types/frameworks/fastify.d.ts +22 -0
  160. package/dist/types/frameworks/hono.d.ts +13 -0
  161. package/dist/types/frameworks/http.d.ts +47 -0
  162. package/dist/types/frameworks/nestjs.d.ts +37 -0
  163. package/dist/types/frameworks/nextjs.d.ts +27 -0
  164. package/dist/types/frameworks/request-context.d.ts +8 -0
  165. package/dist/types/frameworks/request-logger.d.ts +8 -0
  166. package/dist/types/frameworks/shared.d.ts +154 -0
  167. package/dist/types/frameworks/standalone.d.ts +64 -0
  168. package/dist/types/frameworks/sveltekit.d.ts +37 -0
  169. package/dist/types/frameworks/tanstack-start.d.ts +28 -0
  170. package/dist/types/frameworks/workers.d.ts +33 -0
  171. package/dist/types/shared/client-log.d.ts +91 -0
  172. package/dist/types/shared/errors.d.ts +75 -0
  173. package/dist/types/shared/index.d.ts +4 -0
  174. package/dist/types/shared/once.d.ts +2 -0
  175. package/dist/types/shared/remote-delivery.d.ts +32 -0
  176. package/dist/workers.js +626 -0
  177. package/dist/workers.js.map +1 -0
  178. package/dist/workers.mjs +623 -0
  179. package/dist/workers.mjs.map +1 -0
  180. package/exports/client.js +3 -0
  181. package/exports/client.mjs +3 -0
  182. package/exports/connectors/betterstack.js +1 -0
  183. package/exports/connectors/betterstack.mjs +1 -0
  184. package/exports/connectors/otlp.js +1 -0
  185. package/exports/connectors/otlp.mjs +1 -0
  186. package/exports/connectors/posthog.js +1 -0
  187. package/exports/connectors/posthog.mjs +1 -0
  188. package/exports/connectors/sentry.js +1 -0
  189. package/exports/connectors/sentry.mjs +1 -0
  190. package/exports/database.js +1 -0
  191. package/exports/database.mjs +1 -0
  192. package/exports/expo.js +1 -0
  193. package/exports/expo.mjs +1 -0
  194. package/exports/frameworks/elysia.js +1 -0
  195. package/exports/frameworks/elysia.mjs +1 -0
  196. package/exports/frameworks/express.js +1 -0
  197. package/exports/frameworks/express.mjs +1 -0
  198. package/exports/frameworks/fastify.js +1 -0
  199. package/exports/frameworks/fastify.mjs +1 -0
  200. package/exports/frameworks/hono.js +1 -0
  201. package/exports/frameworks/hono.mjs +1 -0
  202. package/exports/frameworks/nestjs.js +1 -0
  203. package/exports/frameworks/nestjs.mjs +1 -0
  204. package/exports/frameworks/nextjs.js +1 -0
  205. package/exports/frameworks/nextjs.mjs +1 -0
  206. package/exports/frameworks/standalone.js +1 -0
  207. package/exports/frameworks/standalone.mjs +1 -0
  208. package/exports/frameworks/sveltekit.js +1 -0
  209. package/exports/frameworks/sveltekit.mjs +1 -0
  210. package/exports/frameworks/tanstack-start.js +1 -0
  211. package/exports/frameworks/tanstack-start.mjs +1 -0
  212. package/exports/workers.js +1 -0
  213. package/exports/workers.mjs +1 -0
  214. package/package.json +291 -0
  215. package/types/client.d.ts +34 -0
  216. package/types/connectors/betterstack.d.ts +1 -0
  217. package/types/connectors/otlp.d.ts +1 -0
  218. package/types/connectors/posthog.d.ts +1 -0
  219. package/types/connectors/sentry.d.ts +1 -0
  220. package/types/database.d.ts +1 -0
  221. package/types/expo.d.ts +17 -0
  222. package/types/frameworks/client.d.ts +160 -0
  223. package/types/frameworks/elysia.d.ts +1 -0
  224. package/types/frameworks/expo.d.ts +50 -0
  225. package/types/frameworks/express.d.ts +1 -0
  226. package/types/frameworks/fastify.d.ts +1 -0
  227. package/types/frameworks/hono.d.ts +1 -0
  228. package/types/frameworks/nestjs.d.ts +1 -0
  229. package/types/frameworks/nextjs.d.ts +1 -0
  230. package/types/frameworks/standalone.d.ts +1 -0
  231. package/types/frameworks/sveltekit.d.ts +1 -0
  232. package/types/frameworks/tanstack-start.d.ts +1 -0
  233. package/types/frameworks/workers.d.ts +115 -0
  234. package/types/index.d.ts +1 -0
  235. package/types/workers.d.ts +13 -0
package/README.md ADDED
@@ -0,0 +1,533 @@
1
+ # Blyp Logger
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.
8
+
9
+ [![Bun](https://img.shields.io/badge/Bun-1.2+-000000?style=flat&logo=bun)](https://bun.sh)
10
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-3178C6?style=flat&logo=typescript)](https://www.typescriptlang.org)
11
+ [![Elysia](https://img.shields.io/badge/Elysia-1.4+-00D8FF?style=flat)](https://elysiajs.com)
12
+
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, 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
+ - **OTLP connector** — Automatic or manual OpenTelemetry log forwarding for Grafana, Datadog, Honeycomb, and any OTLP-compatible backend
21
+ - **Standalone usage** — Use without any framework
22
+ - **Structured file logging** — NDJSON with size-based rotation and gzip archives
23
+ - **Database logging** — Serverless-friendly persistence with Prisma and Drizzle adapters for Postgres and MySQL
24
+ - **Client log sync** — Browser logs ingested into your backend stream
25
+
26
+ ## Project structure
27
+
28
+ ```
29
+ blyp/
30
+ ├── exports/
31
+ │ ├── client.js # Public client entry shim
32
+ │ ├── connectors/
33
+ │ │ └── posthog.js # Public connector entry shims
34
+ │ └── frameworks/
35
+ │ └── elysia.js # Public framework entry shims
36
+ ├── index.ts # Main source export bridge
37
+ ├── src/
38
+ │ ├── core/ # Logger runtime and file logging internals
39
+ │ ├── connectors/ # Connector implementations
40
+ │ ├── frameworks/ # Framework implementations
41
+ │ ├── shared/ # Shared runtime/error utilities
42
+ │ └── types/
43
+ │ ├── framework.types.ts # Shared public contracts
44
+ │ ├── connectors/
45
+ │ │ └── posthog.ts # Connector-specific source types
46
+ │ └── frameworks/
47
+ │ └── elysia.ts # Framework-specific source types
48
+ ├── types/
49
+ │ ├── index.d.ts # Public type entry shim
50
+ │ ├── connectors/
51
+ │ │ └── posthog.d.ts # Public connector type shims
52
+ │ └── frameworks/
53
+ │ └── elysia.d.ts # Public framework type shims
54
+ ├── tests/
55
+ │ ├── frameworks/ # One test file per server integration
56
+ │ ├── helpers/ # Shared test utilities
57
+ │ ├── *.test.ts # Focused core tests
58
+ │ └── README.md # Test documentation
59
+ └── README.md
60
+ ```
61
+
62
+ ## Installation
63
+
64
+ ```bash
65
+ bun add @blyp/core
66
+ npx expo install expo-network
67
+ ```
68
+
69
+ Also: `npm install @blyp/core` | `yarn add @blyp/core` | `pnpm add @blyp/core`
70
+
71
+ ## Usage
72
+
73
+ ### Basic logger
74
+
75
+ ```typescript
76
+ import { logger } from '@blyp/core';
77
+
78
+ logger.info('Hello world');
79
+ logger.success('Operation completed');
80
+ logger.error('Something went wrong');
81
+ logger.warning('Warning message');
82
+ ```
83
+
84
+ ### Structured request batches
85
+
86
+ Standalone usage:
87
+
88
+ ```typescript
89
+ import { createStructuredLog } from '@blyp/core';
90
+
91
+ const structuredLog = createStructuredLog('checkout', {
92
+ service: 'web-api',
93
+ level: 'info',
94
+ timestamp: new Date().toISOString(),
95
+ });
96
+
97
+ structuredLog.set({
98
+ user: { id: 1, plan: 'pro' },
99
+ cart: { items: 3, total: 9999 },
100
+ });
101
+
102
+ structuredLog.info('user logged in');
103
+ structuredLog.info('item added to cart');
104
+ structuredLog.emit({ status: 200 });
105
+ ```
106
+
107
+ Framework usage with Elysia:
108
+
109
+ ```typescript
110
+ import { createStructuredLog } from '@blyp/core';
111
+ import { Elysia } from 'elysia';
112
+ import { createLogger } from '@blyp/core/elysia';
113
+
114
+ const app = new Elysia()
115
+ .use(createLogger({ level: 'info' }))
116
+ .post('/hello', ({ set }) => {
117
+ const structuredLog = createStructuredLog<{
118
+ message: string;
119
+ level: string;
120
+ timestamp: string;
121
+ hostname?: string;
122
+ port?: number;
123
+ }>('test', {
124
+ message: 'Hello Elysia',
125
+ level: 'info',
126
+ timestamp: new Date().toISOString(),
127
+ hostname: app.server?.hostname,
128
+ port: app.server?.port,
129
+ });
130
+
131
+ structuredLog.info('route started');
132
+ structuredLog.emit({ status: 200 });
133
+
134
+ set.status = 200;
135
+ return 'ok';
136
+ });
137
+ ```
138
+
139
+ 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.
140
+
141
+ ### Errors
142
+
143
+ ```typescript
144
+ import { createError } from '@blyp/core';
145
+
146
+ throw createError({ status: 404, message: 'Not found' });
147
+ ```
148
+
149
+ For the full error API (`HTTP_CODES`, `extend`, `create`), see [Full documentation](docs/README.md#errors).
150
+
151
+ ### Framework integrations
152
+
153
+ Blyp supports **Elysia**, **Hono**, **Express**, **Fastify**, **NestJS**, **Next.js**, **TanStack Start**, **SvelteKit**, and **Cloudflare Workers**. Example with Elysia:
154
+
155
+ ```typescript
156
+ import { Elysia } from 'elysia';
157
+ import { createLogger } from '@blyp/core/elysia';
158
+
159
+ const app = new Elysia()
160
+ .use(createLogger({ level: 'info', autoLogging: true }))
161
+ .get('/', () => 'Hello World')
162
+ .listen(3000);
163
+ ```
164
+
165
+ For other frameworks, client logging, advanced configuration, and utilities, see [Full documentation](docs/README.md).
166
+
167
+ ### Expo
168
+
169
+ ```typescript
170
+ import { createExpoLogger } from '@blyp/core/expo';
171
+
172
+ const logger = createExpoLogger({
173
+ endpoint: 'https://api.example.com/inngest',
174
+ });
175
+
176
+ logger.info('app mounted');
177
+ ```
178
+
179
+ 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.
180
+
181
+ ### Database logging
182
+
183
+ 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.
184
+
185
+ Prisma:
186
+
187
+ ```typescript
188
+ import { PrismaClient } from '@prisma/client';
189
+ import { createPrismaDatabaseAdapter } from '@blyp/core/database';
190
+
191
+ const prisma = new PrismaClient();
192
+
193
+ export default {
194
+ destination: 'database',
195
+ database: {
196
+ dialect: 'postgres',
197
+ adapter: createPrismaDatabaseAdapter({
198
+ client: prisma,
199
+ model: 'blypLog',
200
+ }),
201
+ },
202
+ };
203
+ ```
204
+
205
+ Drizzle:
206
+
207
+ ```typescript
208
+ import { createDrizzleDatabaseAdapter } from '@blyp/core/database';
209
+ import { db } from './db';
210
+ import { blypLogs } from './db/schema/blyp';
211
+
212
+ export default {
213
+ destination: 'database',
214
+ database: {
215
+ dialect: 'mysql',
216
+ adapter: createDrizzleDatabaseAdapter({
217
+ db,
218
+ table: blypLogs,
219
+ }),
220
+ },
221
+ };
222
+ ```
223
+
224
+ In database mode, Blyp keeps connectors working as usual and replaces only the primary local persistence backend. Promise-based framework integrations 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.
225
+
226
+ Use the Blyp CLI to scaffold the schema and migrations:
227
+
228
+ ```bash
229
+ blyp logs init --adapter prisma --dialect postgres
230
+ blyp logs init --adapter drizzle --dialect mysql
231
+ ```
232
+
233
+ ### Better Stack
234
+
235
+ Use `connectors.betterstack` when you want Blyp logs forwarded into Better Stack through `@logtail/node`:
236
+
237
+ ```typescript
238
+ export default {
239
+ connectors: {
240
+ betterstack: {
241
+ enabled: true,
242
+ mode: 'auto',
243
+ sourceToken: process.env.SOURCE_TOKEN,
244
+ ingestingHost: process.env.INGESTING_HOST,
245
+ errorTracking: {
246
+ dsn: process.env.BETTERSTACK_ERROR_TRACKING_DSN,
247
+ tracesSampleRate: 1.0,
248
+ },
249
+ },
250
+ },
251
+ };
252
+ ```
253
+
254
+ `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.
255
+
256
+ In `auto` mode, the normal Blyp server loggers forward to Better Stack automatically. In `manual` mode, use `@blyp/core/betterstack`:
257
+
258
+ ```typescript
259
+ import {
260
+ captureBetterStackException,
261
+ createBetterStackErrorTracker,
262
+ createBetterStackLogger,
263
+ createStructuredBetterStackLogger,
264
+ } from '@blyp/core/betterstack';
265
+
266
+ createBetterStackLogger().info('manual better stack log');
267
+ createBetterStackErrorTracker().capture(new Error('manual better stack exception'));
268
+ captureBetterStackException(new Error('wrapped better stack exception'));
269
+
270
+ const structured = createStructuredBetterStackLogger('checkout', {
271
+ orderId: 'ord_123',
272
+ });
273
+ structured.info('manual start');
274
+ structured.emit({ status: 200 });
275
+ ```
276
+
277
+ 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.
278
+
279
+ Browser and Expo loggers can request server-side Better Stack forwarding through the existing ingestion endpoint:
280
+
281
+ ```typescript
282
+ import { createClientLogger } from '@blyp/core/client';
283
+
284
+ const logger = createClientLogger({
285
+ endpoint: '/inngest',
286
+ connector: 'betterstack',
287
+ });
288
+ ```
289
+
290
+ ```typescript
291
+ import { createExpoLogger } from '@blyp/core/expo';
292
+
293
+ const logger = createExpoLogger({
294
+ endpoint: 'https://api.example.com/inngest',
295
+ connector: 'betterstack',
296
+ });
297
+ ```
298
+
299
+ 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.
300
+
301
+ ### PostHog
302
+
303
+ Use `blyp.config.ts` when you want to read the PostHog project key from the environment:
304
+
305
+ ```typescript
306
+ export default {
307
+ connectors: {
308
+ posthog: {
309
+ enabled: true,
310
+ mode: 'auto',
311
+ projectKey: process.env.POSTHOG_PROJECT_KEY,
312
+ errorTracking: {
313
+ enabled: true,
314
+ mode: 'auto',
315
+ },
316
+ },
317
+ },
318
+ };
319
+ ```
320
+
321
+ In `auto` mode, the normal Blyp server loggers forward to PostHog automatically. In `manual` mode, use `@blyp/core/posthog`:
322
+
323
+ ```typescript
324
+ import {
325
+ capturePosthogException,
326
+ createPosthogErrorTracker,
327
+ createPosthogLogger,
328
+ createStructuredPosthogLogger,
329
+ } from '@blyp/core/posthog';
330
+
331
+ createPosthogLogger().info('manual posthog log');
332
+ createPosthogErrorTracker().capture(new Error('manual posthog exception'));
333
+ capturePosthogException(new Error('wrapped posthog exception'));
334
+
335
+ const structured = createStructuredPosthogLogger('checkout', { orderId: 'ord_123' });
336
+ structured.info('manual start');
337
+ structured.emit({ status: 200 });
338
+ ```
339
+
340
+ `connectors.posthog.errorTracking.mode: 'auto'` also captures Blyp handled server errors and can enable uncaught exception / unhandled rejection autocapture through `enableExceptionAutocapture`.
341
+
342
+ Browser and Expo loggers can request server-side PostHog forwarding through the existing ingestion endpoint:
343
+
344
+ ```typescript
345
+ import { createClientLogger } from '@blyp/core/client';
346
+
347
+ const logger = createClientLogger({
348
+ endpoint: '/inngest',
349
+ connector: 'posthog',
350
+ });
351
+ ```
352
+
353
+ 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.
354
+
355
+ 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.
356
+
357
+ ### Sentry
358
+
359
+ Use `connectors.sentry` when you want Blyp logs forwarded into Sentry Logs:
360
+
361
+ ```typescript
362
+ export default {
363
+ connectors: {
364
+ sentry: {
365
+ enabled: true,
366
+ mode: 'auto',
367
+ dsn: process.env.SENTRY_DSN,
368
+ environment: process.env.SENTRY_ENVIRONMENT,
369
+ release: process.env.SENTRY_RELEASE,
370
+ },
371
+ },
372
+ };
373
+ ```
374
+
375
+ In `auto` mode, normal Blyp server loggers forward to Sentry automatically. In `manual` mode, use `@blyp/core/sentry`:
376
+
377
+ ```typescript
378
+ import { createSentryLogger, createStructuredSentryLogger } from '@blyp/core/sentry';
379
+
380
+ createSentryLogger().info('manual sentry log');
381
+
382
+ const structured = createStructuredSentryLogger('checkout', {
383
+ orderId: 'ord_123',
384
+ });
385
+ structured.info('manual start');
386
+ structured.emit({ status: 200 });
387
+ ```
388
+
389
+ Browser and Expo loggers can request server-side forwarding through Blyp's ingestion endpoint:
390
+
391
+ ```typescript
392
+ import { createClientLogger } from '@blyp/core/client';
393
+
394
+ const logger = createClientLogger({
395
+ endpoint: '/inngest',
396
+ connector: 'sentry',
397
+ });
398
+ ```
399
+
400
+ ```typescript
401
+ import { createExpoLogger } from '@blyp/core/expo';
402
+
403
+ const logger = createExpoLogger({
404
+ endpoint: 'https://api.example.com/inngest',
405
+ connector: 'sentry',
406
+ });
407
+ ```
408
+
409
+ 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.
410
+
411
+ ### OTLP
412
+
413
+ 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:
414
+
415
+ ```typescript
416
+ export default {
417
+ connectors: {
418
+ otlp: [
419
+ {
420
+ name: 'grafana',
421
+ enabled: true,
422
+ mode: 'auto',
423
+ endpoint: 'http://localhost:4318',
424
+ headers: {
425
+ 'x-scope-orgid': process.env.GRAFANA_SCOPE_ID!,
426
+ },
427
+ auth: process.env.GRAFANA_AUTH,
428
+ },
429
+ {
430
+ name: 'honeycomb',
431
+ enabled: true,
432
+ mode: 'manual',
433
+ endpoint: 'https://api.honeycomb.io',
434
+ headers: {
435
+ 'x-honeycomb-team': process.env.HONEYCOMB_API_KEY!,
436
+ },
437
+ },
438
+ ],
439
+ },
440
+ };
441
+ ```
442
+
443
+ 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:
444
+
445
+ ```typescript
446
+ import { createOtlpLogger, createStructuredOtlpLogger } from '@blyp/core/otlp';
447
+
448
+ createOtlpLogger({
449
+ name: 'grafana',
450
+ }).info('manual otlp log');
451
+
452
+ const structured = createStructuredOtlpLogger(
453
+ 'checkout',
454
+ { orderId: 'ord_123' },
455
+ { name: 'honeycomb' }
456
+ );
457
+ structured.info('manual start');
458
+ structured.emit({ status: 200 });
459
+ ```
460
+
461
+ Browser and Expo loggers can request server-side forwarding to a named OTLP target through the existing ingestion endpoint:
462
+
463
+ ```typescript
464
+ import { createClientLogger } from '@blyp/core/client';
465
+
466
+ const logger = createClientLogger({
467
+ endpoint: '/inngest',
468
+ connector: { type: 'otlp', name: 'grafana' },
469
+ });
470
+ ```
471
+
472
+ ```typescript
473
+ import { createExpoLogger } from '@blyp/core/expo';
474
+
475
+ const logger = createExpoLogger({
476
+ endpoint: 'https://api.example.com/inngest',
477
+ connector: { type: 'otlp', name: 'grafana' },
478
+ });
479
+ ```
480
+
481
+ 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.
482
+
483
+ Log levels, HTTP request logging, and file logging (rotation, archives, reading stored logs) are documented in [docs](docs/README.md#file-logging).
484
+
485
+ ## Testing
486
+
487
+ Run tests:
488
+
489
+ ```bash
490
+ bun run test
491
+ ```
492
+
493
+ 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).
494
+
495
+ ## Development
496
+
497
+ **Prerequisites:** [Bun](https://bun.sh) 1.2+ (or [Node.js](https://nodejs.org) 18+), [TypeScript](https://www.typescriptlang.org) 5.0+
498
+
499
+ ```bash
500
+ git clone https://github.com/Blyphq/blyp.git
501
+ cd blyp
502
+ bun install
503
+ bun run test
504
+ bun run build
505
+ bun run type-check
506
+ ```
507
+
508
+ ## Publishing
509
+
510
+ GitHub Actions publishes the package to npm when a GitHub Release is published. Add an `NPM_TOKEN` repository secret before using the workflow.
511
+
512
+ ## Contributing
513
+
514
+ Contributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for how to get set up and submit changes.
515
+
516
+ ## License
517
+
518
+ This project is licensed under the MIT License — see the [LICENSE](LICENSE) file for details.
519
+
520
+ ## Acknowledgments
521
+
522
+ [Winston](https://github.com/winstonjs/winston) · [Elysia](https://elysiajs.com) · [Chalk](https://github.com/chalk/chalk) · [Bun](https://bun.sh)
523
+
524
+ ## Links
525
+
526
+ - [GitHub Repository](https://github.com/Blyphq/blyp)
527
+ - [NPM Package](https://www.npmjs.com/package/@blyp/core)
528
+ - [Documentation](docs/README.md)
529
+ - [Issues](https://github.com/Blyphq/blyp/issues)
530
+
531
+ ---
532
+
533
+ *Blyp silently watches over your applications, logging everything that happens under its watchful gaze.*