Blyp Docs

Database Logging

Use database logging when your deployment cannot rely on local file persistence, especially in serverless environments.

Database mode changes Blyp's primary sink from files to your database. Connectors such as Better Stack, PostHog, Sentry, and OTLP continue to work independently.

Requirements

blyp.config.json alone is not enough for this mode because adapters are runtime objects.

Supported setups

CLI setup available: You can scaffold the schema, run migrations, and generate blyp.config.ts automatically using blyp db:init. See the CLI docs for the guided setup flow.

Prisma example

import { PrismaClient } from "@prisma/client";
import { createPrismaDatabaseAdapter } from "@blyp/core/database";

const prisma = new PrismaClient();

export default {
  destination: "database",
  database: {
    dialect: "postgres",
    adapter: createPrismaDatabaseAdapter({
      client: prisma,
      model: "blypLog",
    }),
  },
};

Drizzle example

import { createDrizzleDatabaseAdapter } from "@blyp/core/database";
import { db } from "./db";
import { blypLogs } from "./db/schema/blyp";

export default {
  destination: "database",
  database: {
    dialect: "mysql",
    adapter: createDrizzleDatabaseAdapter({
      db,
      table: blypLogs,
    }),
  },
};

Delivery behavior

The database delivery queue supports immediate writes and batched writes.

Default values:

export default {
  destination: "database",
  database: {
    dialect: "postgres",
    adapter,
    delivery: {
      strategy: "batch",
      batchSize: 50,
      flushIntervalMs: 1000,
    },
  },
};

Flushing and shutdown

All Blyp loggers expose:

await logger.flush();
await logger.shutdown();

Promise-based integrations such as Elysia, Hono, Next.js, SvelteKit, and TanStack Start flush automatically in database mode before the request completes.

For callback-style servers such as Express, Fastify, and NestJS, call await logger.flush() at your own boundary when you need a hard durability point.

CLI-assisted setup

As of CLI v0.1.3, the recommended setup flow is:

blyp db:init
blyp db:migrate
blyp db:generate

db:generate is only needed for Prisma projects.

Without a global install:

bunx @blyp/cli db:init
bunx @blyp/cli db:migrate
bunx @blyp/cli db:generate

Import paths

Use: